Question: java Goals and Objectives: 1. Create super-classes and sub-classes 2. Use constructors belonging to super-classes 3. Create objects of super-classes and sub-classes and execute methods


Goals and Objectives: 1. Create super-classes and sub-classes 2. Use constructors belonging to super-classes 3. Create objects of super-classes and sub-classes and execute methods of both classes using these objects 4. Override methods inherited from super classes Instructions: Make sure that you follow the Program Style and Readability guidelines found in the Start Here Folder. 1. Start with a working Point class. Refer to the Point program created for Lab #1: 2. Write a new Rectangle class, a subclass of the Point class. a. Add width and length variables to the new class. b. Add constructors i. a default Rectangle()where width = 15, length = 15 ii. a 2 argument constructor Rectangle(width, length) iii. use the Super() default constructor for the x, y values c. Add get and set() methods as needed to support your new instance variables. d. Add a method called area that: i. Calculates the area of a Rectangle object: Area- length*width ii. returns the Area of a Rectangle object iii. Do not store the area in a member variable. e. Override the toString method found in class Point to display (and label) all of the characteristics (instance variables) of a Rectangle object. Do not forget to include the original point instance variables by using the super.toString. 3. Write a new Box class, a subclass of the Rectangle class. a. Add height as a new variable in this class b. Add constructors i. a default Box() where width - 15, length - 15, height = 15 b. Add constructors i. a default Box() where width = 15, length - 15, height = 15 ii. a 1 argument constructor Box(height) iii. use the Super() default constructor for the x, y, width, height values c. Add get() and set() methods as needed. d. Override the area method inherited from the Rectangle class to calculate the outside face area (6 sides) of a Box object. i. Calculates: Area= length * width * 2 + width * height * 2 + length * height * 2 ii. returns the area of a Rectangle object O iii. Do not store the area in a member variable. e. Add a method called volume that: i. Calculates the volume of a Box object: Volume = length * width * height. ii. returns the volume of a Box object iii. Do not store the volume in a member variable. f. Override the toString method inherited from class Rectangle to display (and label) all of the characteristics (instance variables) of a Box object. Do not forget to include the original point and rectangle instance variables by using the super.toString(). 4. Write an executable client class called Shapes Tester - a separate program - that uses the Point, Rectangle and Box classes. a. Print your name, Lab number, and date as the first three lines of output. Hard-code the date...do not use the system date. - Write an executable client class called Shapes Tester - a separate program - that uses the Point, Rectangle and Box classes. a. Print your name, Lab number, and date as the first three lines of output. Hard-code the date...do not use the system date. b. Create two objects of type Point, i. pointl = Point ii. point2 = Point(5,19) c. Create two objects of type Rectangle i. rectanglel = Rectangle() ii. rectangle2 = Rectangle(24, 30) d. Create two objects of type Box. i boxi - Box ii.box2 = Box(60) e. Execute the area () methods for all objects of type Rectangle and Box. The area should be printed from the Shapes Tester class. Remember the area is being returned to the client. f. Execute the volume and area() methods for all objects of type Box. The volume should be printed from the Shapes class. Remember the volume is being returned to the client. g. Change the width of box2 to 21 h. Execute the volume and area() methods for box2. The volume should be printed from the Shapes Tester class. Remember the volume is being returned to the client. i. Execute the toString() method for all objects. / Fig. 8.1: Time1.java Timel class declaration maintains the time in 24-hour format. public class Timel private int hour: // 0 - 23 private int minute; // 0 - 59 private int second; // 0 - 59 1/ set a new time value using universal time; throw an // exception if the hour, minute or second is invalid public void setTime(int hour, int minute, int second) // validate hour, minute and second if (hour 24 Il minute
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
