Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1 Author -name: string - email:string -gender:char = Book -name: string -author:Author -price: double -qtyInStock: int = 0 +Book(name:string, author:Author, price:double, qtyInStock:int) +getName():string +getAuthor(): Author

image text in transcribed

1 Author -name: string - email:string -gender:char = Book -name: string -author:Author -price: double -qtyInStock: int = 0 +Book(name:string, author:Author, price:double, qtyInStock:int) +getName():string +getAuthor(): Author +getPrice(): double +setPrice (price: double):void +getQtyInStock():int +setQtyInStock(qtyInStock:int):void +print():void +getAuthorName():string Design a Book class. Assume that a book is written by one and only one author. The Book class (as shown in the class diagram) contains the following members: 1. Four private data members: name (string), author (an instance of the class Author that we have created earlier), price (double), and qtyInStock (int, with default value of 0). The price shall be positive and the atyInStock shall be zero or positive. 2. Take note that data member author is an instance (object) of the class Author, instead of a fundamental types (such as int, double). In fact, name is an object of the class string too. 3. The public getters and setters for the private data members. Take note that getAuthor( returns an object (an instance of class Author). 4. A public member function print, which prints "book-name' by author- name (gender) @ email". 5. A public member function getAuthorName(), which returns the name of the author of this Book instance. 6. The hallow diamond shape in the class diagram denotes aggregation or has-a) association relationship. That is, a Book instance has one (and only one) Author instance as its component

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Informix Database Administrators Survival Guide

Authors: Joe Lumbley

1st Edition

0131243144, 978-0131243149

More Books

Students also viewed these Databases questions