Assignment
Assignment
Assignment
Learning outcome:
Upon successful completion of this assignment, you will have demonstrated the abilities to:
• Uses streams to read and write data from/to different types of sources/targets
• Identify classes, objects, members of a class, and relationships among them needed for a
specific problem
• Explain the concept and demonstrates the use of Polymorphism, Encapsulation,
Abstraction, and Inheritance in java
1
❖ Read in student code, select “Find” button, the corresponding student information
is displayed
❖ Read in student code, select “Delete” button, the corresponding student is
removed from the list
❖ Read in student class, select “Delete Class” button, all the students of the class is
removed from the list
❖ Read in student code and class, select “Check” button, student class is checked
and displayed
Select “Best Student” button, first-found student having largest average grade is displayed
Project 2: BOOK MANAGEMENT IN THE LIBRARY PROGRAM
Program Requirements:
Using array, develop application that manages book information in a library
1) Define “Book class” that includes:
o Attributes:
▪ Book title
▪ Author
▪ Published year
▪ Book unit price
▪ Book quantity
o Methods:
▪ Initiate the attributes of “Book” class
▪ Needed accessor methods (getters) and mutator methods (setters)
▪ Calculate total book price = quantity x book unit price
▪ Calculate transport price. It is known:
Quantity Transport price
<=50 0
50 < quantity <= 500 2% of book price
otherwise 5% of book price
2) Define class “BookArray” to manage book information in a library. Each element in
the list has the data type of “Book” class
Methods of the class:
o Add a book to the array
o Calculate the total book price (including transport price)
o Delete the book corresponding with specified book code
o Find out the book corresponding with specified book code
o Find out the book having largest quantity in the library
3) Define graphics user interface class that supplies a input and output interface for book
information. When the user selects “Add”, “Price”, “Delete”, “Find”, “Largest Quantity”
buttons, the corresponding method defined in the array class is called:
2
o Read in book information, select “Add” button, the book information is added to
the array
o Select “Price” button, the total book price (including transport price) of the books
in the library is calculated
o Read in book code, select “Delete” button, the corresponding book is removed
from the list
o Select “Find” button, the information of book having specified book code is
displayed
o Select “Largest Quantity” button, the information of book having largest quantity
is displayed
3
• Add a bill to the list
• Find out the bill corresponding with specified bill code
• Calculate the total bill payment of customers belonging among
specified customer type
• Delete the bill corresponding with specified customer code
• Find out the bill having largest payment
o Define graphics user interface class that supplies a input and output interface for
bill information
▪ When the user selects “Add”, “Find”, “Payment”, “Delete”, “Largest
Payment” buttons, the corresponding method defined in the array class is
called
▪ Read in bill information, select “Add” button, the bill information is added
to the list
▪ Read in bill code, select “Find” button, the information of bill having the
bill code is displayed
▪ Read in customer type, select “Payment” button, the total payment of the
bills belonging among the customer type is calculated
▪ Read in customer code, select “Delete” button, the corresponding bill is
removed from the list
▪ Select “Largest Payment” button, the information of bill having the total
largest payment is displayed
- If the user chooses 1 then add one record to data including Code(String), Name(String),
Specialization(String), Availability(int).
- If user chooses 2: then request enter the code. If it does not exist Code, the notification
"Doctor code does not exist". Otherwiseuser can edit of the remaining information. If
Information is blank then not change old information.
- If user chooses 3: the Code requires the user to enter Code and delete information if Code
exists, if Code does not exist,, the notification "code does not exist Doctor".
- If user chooses 4: require user to enter search strings, search and returns the list for users.
- If user chooses 5: exit the program.
Function details:
4
Function 1: Display GUIand Input Data.
• User runs the program. The program prompts users input Data.
• Auto next Function2.
Function 2: Perform function based on the selected option.
5
o Prompt users input values of matrixes must be the number. If users input values
that are not a number, display notification on the screen: “Values of matrix must
be the number”.
Implement the Shape hierarchy shown in above figure. Each two-dimensional shape should
contains method getArea() to calculate the area of it (e.g area of a circle is pi* r2).
Each three-dimensional shape should contain getArea() and getVolume() methods to calculate
the surface area and volume respectively.
Create a program that uses an array of Shape references to objects of each concrete class in the
hierarchy. The program should print the object to which each array element refers.
Also in the loop that processes all the shapes in the array, determine whether each shape is a two-
dimensional shape or three-dimensional shape. If a shape is two-dimensional one, display its
area. If a shape is three -dimensional one, display its area and volume.
Project 7: Bees.
Write classes to represent 3 different types of Bee - Worker, Queen and Drone.
6
Each Bee has a floating-point health property, which is not writable externally and upon creation
is set to a value of 100 (percent).
Each Bee has a Damage() method that takes a single integer parameter that should be a value
between 0 and 100. When this method is called, the health of the bee is to be reduced by that
percentage of their current health.
When a Worker has a health below 70% it cannot fly and therefore is pronounced Dead. When a
Queen has a health below 20%, or a Drone below 50%, it is pronounced dead. This 'Dead'
property should be readable from each Bee. When a Bee is dead, no further health deductions
should be recorded by the bee, although the Damage() method should still be invokable without
error.
Your application should create a single list containing 10 instances of each type of Bee and store
in a list or array. It must support methods to allow Damage() to be called for each Bee, and to
return the health status of each bee, including whether it is alive or not.
Your application interface must contains 2 functions (user press “1” or “2” to activate this
function :
1 – Create bee list – Clear current bee list and create new random bees, then display in the
console windows
2 – Attack bees - Attack current bee list, a different random value between 0 and 80 should be
selected for each bee and applied with a call to Damage(). After attacked, the user interface
should refresh to show the health status of the bees in console windows