Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java program to run in NetBeans 8.2 Book - title: String - price: double + Book() + Book(String, double) + getTitle(): String + setTitle(String): void

image text in transcribedJava program to run in NetBeans 8.2

Book - title: String - price: double + Book() + Book(String, double) + getTitle(): String + setTitle(String): void + getPrice(): double + setPrice(double): void + toString(): String The left side diagram is a UML diagram for Book class. The class has two attributes, title and price, and get/set methods for the two attributes, The first constructor doesn't have a parameter. It assigns "" to title and 0.0 to price; The second constructor uses passed-in parameters to initialize the two attributes. The toString() method returns values for the two attributes. Notation: - means private, and + means public a) Define the Book.java class. b) Then define another class named BookApp.java which has a main() method. c) This BookApp class interacts with the Book class as follows: you create a Book object, named b1, by calling the first Book constructor. Then using the object b1 to call setTitle() and setPrice() methods to assign "John Doe" to title and 8.1 to price. Finally, using b1 to call toString() method and print the returned value from the toString() method You create another Book object, named b2, by calling the second Book constructor and passing "Ann Smith" as the first argument and 9.2 as the second argument. Finally, using b2 to call toString() method and print the returned value from the toString() method. d) Run the BookApp program to make sure it works correctly

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

Step: 3

blur-text-image

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

More Books

Students also viewed these Databases questions

Question

What classes of input will make good test cases?

Answered: 1 week ago

Question

Describe key employee expectations.

Answered: 1 week ago