Session 3 Application Ex
Session 3 Application Ex
Question:
1.1-What are the oop concepts depicted on the diagram? Explain each of them.
1.2-Write the Java code of each of the classes. Note: student and staff classes are inherited
from
person.
1.3-Write a test driver for person.
2-
1/4
Page 1 of 4
Kougang Guy Rostand [email protected]
The Customer class models a customer is design as shown in the class diagram.
Write the
codes for the Customer class and a test driver to test all the public methods.
The Account class models a bank account, design as shown in the class diagram,
composes a Customer instance (written earlier) as its member. Write the codes for the
Account class and a test driver to test all the public methods.
Write the test driver of an Account.
3-
A class called Author, which models an author of a book, is designed as shown in the class
diagram. A class called Book, which models a book written by ONE author and composes an
instance of Author as its instance variable, is also shown. Write the classes of Author
and Book then their test driver of Book.
2/4
Page 2 of 4
Kougang Guy Rostand [email protected]
4- -Define a Money class, suitable for storing money information. Class objects should
contain two int fields: euros and centimes. Write for the class appropriate constructors
and get/set methods to allow the user to access its data. Also write a print methods
that prints out an object's info. Overload the + operator, so that adding two objects of this
class works. As an added requirement, after adding two Money objects, values of more than
100 centimes should be converted to euros.
As an example: once your class is ready the piece of code Money m(2,99); (m+m+m).print();
should produce the following output: “8,97 Euros”
3/4
Page 3 of 4
Kougang Guy Rostand [email protected]
5- -Define a CreditCard class. Each object should contain the following information:
owner name (string), card number (string) and a linked list of transactions. Each transaction
should include an item name (string), and a cost (Money class from exercise 12). Pay
special attention to writing appropriate constructors/destructors. Write a print( ) method
that prints out all the transaction history of the credit card, and two charge methods
which add new transactions to the card. One charge method should take as parameters
a string (the item name) and a Money object. The other should take a string and two
integers (describing the price in euros, centimes).
4/4
Page 4 of 4
Kougang Guy Rostand [email protected]