Association (Solve Needed)

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

AMERICAN INTERNATIONAL UNIVERSITY-BANGLADESH (AIUB)

Faculty of Science and Technology (FST)


Department of Computer Science (CS)
Object Oriented Programming 1
Assignment on Association

Project/Program Organization (Each file contains only one java class)


 We will create individual folder/directory for each program or pro-
ject.
 We will develop each class in a separate file.
Develop Following Java classes:
Note: Student must follow the exact name of class, member variables,
and functions as well camel notions.

1.Account String accName Member variables


String acid declare private
int balance
2 Constructor (Empty, valued)
Department of Computer Science, AIUB

deposit(int amount)
Withdraw(int amount)
Additional part

transfer(int amount, Account receiver) Transfer amount from


one account to an-
other account

2.Book String bookName Member variables


String bookAuthor declare private
String bookId
String bookType
int bookCopy // how many copy
2 Constructor (Empty, valued)
void showInfo()
void addBookCopy(int x)// how many copy of book
To count the total number of book object use static modifier to
count book object.
If static is covered in your theory class only then you precede
this.
static int bookCounter
static void showTotalBookInfo()

© Dept. of Computer Science, FST, AMERICAN INTERNATIONAL UNIVERSITY-BANGLADESH (AIUB) 1


3.Contact String personName Member varia-
String personId bles declare
int age private
String mobileNumber;
Char gender // M or F
2 Constructor // empty and valued void
showPersonInfo()
void detectMobileOperator() // it will
show GP or Robi or Banglalink depend upon
the operator

4.Mobile String mobileOwnerName


String mobileNumber // SIM number
String mobileBalance
String mobileOSName
boolean lock // true means phone is lock false
means unlock
2 constructor Lock has to be
void show- false to show
Info() or recharge or
void recharge(int amount) call someone,
void callSomeone(int timeDuration) // per minute so check the
cost=1 taka lock flag/Bool-
ean variable

5.Library String libName Member varia-


String libAddress bles declare
Reuse Book Book [] books private
Class int totalBook;
2 constructors (empty and valued)
void showLibInfo() // show library info and all
book info as well
void addNewBook(Book book) // add a new book
into lib
void addNewBookCopy(Book book, int copy)

6.Address- String ownerName


Book String info
Contact [] listOfContact
Reuse totalContact
Contact 2 constructor (empty and
Class valued)
void showAllContactInfo()
void addContact(Contact con)

© Dept. of Computer Science, FST, AMERICAN INTERNATIONAL UNIVERSITY-BANGLADESH (AIUB) 2


Up-gradation of Account class
7.Account accId, accName, accBalance

use all the previous methods and constructors


(just copy from that class)

Additional part
(We want to preserve history of transactions for each account object. To do so
we need to develop one more class name Transaction)
8.Transaction Account sender
Account receiver
int amount
String additional-
Info 2 constructors
showInfo()

In the Account class use one/two more member variable to store transaction in-
formation and necessary member functions.
Transaction [] listOfTransaction //member
variable int totalNumberOfTransaction // mem-
ber variable

void addTransaction(Account sender, Account re-


ceiver, int amount)

void showAllTranscation()

© Dept. of Computer Science, FST, AMERICAN INTERNATIONAL UNIVERSITY-BANGLADESH (AIUB) 3


Bonus Part
Now we want to reuse our Account class. The scenario is every student ob-
ject has an account.
Tasks that you have to do:
1. If a student deposit a book after certain duration then for each day 10
taka will be charged by the library authority.
2. Student can pay that amount (charged amount) from his/her bank account
to the library account. So the library also has an account.
3. Show the total amount a student paid to the library.
4. Show the total amount library gets from the students (total charged
amount).
5. But if any student has any valid reason for delay then the librarian
can excuse the charged amount. Librarian can excuse full or partially
(%).
In this program we want to reuse our last developed Library and Student
Class. Our objective is to develop the scenario, where student can take
maximum 5 books (for 5 days each) at a time from the library, and return
these books.
Tasks that you have to do:
1. Show all the borrowed book information of a student from student
class
2. Show all the student name and book information from library class,
which are currently borrowed by students.
3. Preserve borrowed history of student object, which he/she takes
in his/her lifetime.
4. Preserve borrowed history of book objects that are taken by students.

© Dept. of Computer Science, FST, AMERICAN INTERNATIONAL UNIVERSITY-BANGLADESH (AIUB) 4

You might also like