Question
Reuse Book.java in Assignment 2 as parent class, refer to the following requirements and UML diagram, The first constructor, TextBook(), doesnt have a parameter. It
Reuse Book.java in Assignment 2 as parent class, refer to the following requirements and UML diagram, The first constructor, TextBook(), doesnt have a parameter. It assigns to title, 0.0 to price, 0 to courseID; The second constructor, TextBook(String, double, int) uses three passed-in parameters to initialize the three attributes. toString() in TextBook returns a string value for the three attributes, title, price, and courseID. Book - title: String - price: double + Book() + Book(String, double) + getTitle(): String + setTitle(String): void + getPrice(): double + setPrice(double): void + toString(): String TextBook - courseID: int + TextBook() + TextBook(String, double, int) + getCourseID(): int + setCourseID(int): void + toString(): String Questions: 1) Define a child class, TextBook, based on above requirement. 2) Define another class, TextBookApp. This TextBookApp class interacts with the Book and TextBook classes as follows: 2.1) Create a Book object, named b, by calling the second Book constructor and passing Ann Smith as the first argument and 9.2 as the second argument. Use b to call toString() method and print the returned value from the toString() method. 2.2) Create a TextBook object, named tb1, by calling the first TextBook constructor. Then using the object tb1 to call methods to assign John Doe to title, 8.1 to price, and 2050 to courseID. Finally, using tb1 to call toString() method and print out the returned value. 2.3) Create another TextBook object, named tb2, by calling the second TextBook constructor and passing Ann Smith as the first argument, 9.2 as the second argument, and 3090 as the third parameter. Use tb2 to call toString() method and print out the returned value. 2.4) Run TextBookApp to make sure it works correctly.
Reuse Book.java in Assignment 2 as parent class, refer to the following requirements and UML diagram, The first constructor, TextBook(), doesn't have a parameter. It assigns to title, 0.0 to price, 0 to courselD; The second constructor, TextBook(String, double, int) uses three passed-in parameters to initialize the three attributes. toString() in TextBook returns a string value for the three attributes, title, price, and courselD. Book Questions: 1) Define a child class, TextBook, based on above requirement. - title: String - price: double + Book() + Book(String, double) +getTitle(0: String + setTitle(String): void +getPrice(): double + setPrice(double): void toString(): String 2) Define another class, TextBookApp. This TextBookApp class interacts with the Book and TextBook classes as follows 2.1) Create a Book object, named b, by calling the second Book constructor and passing "Ann Smith" as the first argument and 9.2 as the second argument. Use b to call toString() method and print the returned value from the toString) method. 2.2) Create a TextBook object, named tb1, by calling the first TextBook constructor. Then using the object tb1 to call methods to assign "John Doe" to title, 8.1 to price, and 2050 to courselD. Finally, using tb1 to call toString() method and print out the returned value. TextBook - courseID: int + TextBook() + TextBook(String, double, int) 2.3) Create another TextBook object, named tb2, by calling the second TextBook constructor and passing "Ann Smith" as the first argument, 9.2 as the second argument, and 3090 as the third parameter. Use tb2 to call toString() method and print out the returned value. getCourselD(): int +setCourselD(int): void + toString(): String 2.4) Run TextBookApp to make sure it works correctlyStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started