Using Java and C++
Lab Task 1:
A class called Book is designed (as shown in the class diagram) to model a book written by one author. It contains:
Four private instance variables: name (String), price (double), static, and qty (int);
Two constructors:
- public Book(String name, double price)
- public Book(String name, double price, int qty)
Getters/setters methods:
- getName()
- getPrice()
- setPrice()
- getQty()
- setQty()
toString() method that returns book values.
A class called Author is designed to model a book's author. It contains:
Four private instance variables: name (String), email (String), and gender (char of either 'm' or 'f') and arrayList of Books.
One constructor to initialize the name, email, and gender with the given values:
- public Author(String name, String email, char gender)
Public getters/setters.
toString() method that returns author object.
A method addBook(Book b) which will add a book in the ArrayList of books.
A method removeBook(String name) which removes a particular book from the list.
Also, write a test driver called to test all the public methods in the class Author.