1. Complete the following tasks: a. Design a class named Circle with fields named radius, area, and diameter. Include a constructor that sets the radius to 1. Include get methods for each field, but include a set method only for the radius. When the radius is set, do not allow it to be zero or a negative number. When the radius is set, calculate the diameter ( twice the radius) and the area ( the radius squared times pi, which is approximately 3.14). Create the class diagram and write the pseudocode that defines the class.
2. 2. Complete the following tasks: a. Design a class named Square with fields that hold the length of a side, the length of the perimeter, and the area. Include a constructor that sets the length of a side to 1. Include get methods for each field, but include a set method only for the length of a side, and do not allow a side to be zero or negative. When the side is set, calculate the perimeter length ( four times the side length) and the area ( a side squared). Create the class diagram and write the pseudocode that defines the class.
b. Design an application that declares two Squares. Set the side length of one manually, but allow the other to use the default value supplied by the constructor. Then, display each Square’s values.
6. Complete the following tasks: a. Design a class named Book that holds a stock number, author, title, price, and number of pages for a book. Include methods to set and get the values for each data field. Also include a displayInfo() method that displays each of the Book’s data fields with explanations.
b. Design a class named TextBook that is a child class of Book. Include a new data field for the grade level of the book. Override the Book class displayInfo() method so that you accommodate the new grade- level field.
c. Design an application that instantiates an object of each type and demonstrates all the methods
Try it now!
How it works?
Follow these simple steps to get your paper done
Place your order
Fill in the order form and provide all details of your assignment.
Proceed with the payment
Choose the payment system that suits you most.
Receive the final file
Once your paper is ready, we will email it to you.