Object Oriented Programming Exercises
Object Oriented Programming Exercises
https://www.informit.com/articles/article.aspx?p=2199423&seqNum=5
https://www.javatpoint.com/banking-application-in-java
Lesson 5.
a. Write a CD object builder program that includes the following properties:
+ CD code is integer number,
+ Title CD: string,
+ Singer: string,
+ Song number: integer (> 0)
+ Cost: real number (> 0)
- Private declaration attributes, define get / set methods for each attribute.
- Write constructors to initialize CD objects.
- Override the toString method of Object class.
b. Build class to save the list of CDs (using array).
- Method of adding a CD to the list.
- The total cost of CDs.
- The method of arranging lists decreases with price.
- The method of arranging the list gradually increases according to CD.
- Method of exporting the entire list.
c. Write class for testing.
II. LAB 4 - INHERITANCE
Lesson 1. Travel company V manages information as trips. Information of 2
types of vehicles:
City bus trip: Trip number, driver's name, vehicle number, route number,
travel kilometers, revenue.
Suburban bus: Trip number, driver's name, vehicle number, destination,
number of travel days, revenue.
Perform the following requirements:
Build classes with inheritance functions.
Write a program to manage vehicles in the form of inheritance trees
with the following methods:
- Import, export the list of trips (list can use array structure).
- Calculate the total revenue for each type of vehicle.
Lesson 2. Library X manages the list of books. Information about book types:
* Textbook: Book code, date of entry, unit price, quantity, publisher, status
(new, old).
If the book status is new: then money = quantity * unit price.
If the book status is old, then money: = quantity * unit price * 50%
* Reference book: Book code, date of entry, unit price, quantity, publisher,
tax. Amount = quantity * unit price + tax
Perform the following requirements:
- Build classes with inheritance functions.
- Import export list of book types.
- Calculate the sum of money for each type.
- Calculate the average of the unit price of the reference books.
- Export textbooks of publisher X.