subject

Define an interface named Shape with a single method named area that calculates the area of the geometric shape: public double area();

Next, define a class named Circle that implements Shape. The Circle class should have an instance variable for the radius, a constructor that sets the radius, an accessor and a mutator method for the radius, and an implementation of the area method.
Define another class named Rectangle that implements Shape. The Rectangle class should have instance variables for the height and the width, a constructor that sets the height and the width, accessor/mutator methods for the height and the width, and an implementation of the area method.
The following test code should then output the area of the Circle and Rectangle objects:

public static void main (String[] args) {

Circle c = new Circle(4); //Radius=4
Rectangle r = new Rectangle(4, 3); // Height = 4, Width = 3

ShowArea(c);
ShowArea(r);

}

public static void ShowArea(Shape s) {

double area = s. area();

System. out. println("The area of the shape is " + area);

}

Defining an Inner Class

Rewrite the given classes Employee, HourlyEmployee, so that the class Date is an inner class of the class Employee and an inherited class of the class HourlyEmployee.
Write a program to instantiate at least two objects each of type Employee and HourlyEmployee. Display the hire dates for each employee and then modify and display the hire dates for each of the employees.

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 19:20
Number of megabytes of ram in a computer. qualitative or quantitative? because
Answers: 3
question
Computers and Technology, 22.06.2019 06:30
Selective incapacitation is a strategy to reduce prison population
Answers: 3
question
Computers and Technology, 22.06.2019 10:30
You have a large, late-model pick-up truck with a rear seat. the pick-up truck weighs 6,500 pounds. the florida seat belt law
Answers: 1
question
Computers and Technology, 22.06.2019 19:10
10. when you create a pivottable, you need to specify where to find the data for the pivottable. is it true
Answers: 2
You know the right answer?
Define an interface named Shape with a single method named area that calculates the area of the geom...
Questions
question
Mathematics, 12.09.2019 17:30
Questions on the website: 13722367