Computers and Technology

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.

answer
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 02:00, vane1161
Aletter or menu command that starts an action when the user presses the designated letter and the alt key together is called what?
Answers: 1
image
Computers and Technology, 22.06.2019 06:50, phillipfruge3
Match the personality traits with their description
Answers: 1
image
Computers and Technology, 22.06.2019 22:30, josephmelichar777
Write a full class definition for a class named player , and containing the following members: a data member name of type string .a data member score of type int .a member function called setname that accepts a parameter and assigns it to name . the function returns no value. a member function called setscore that accepts a parameter and assigns it to score . the function returns no value. a member function called getname that accepts no parameters and returns the value of name .a member function called getscore that accepts no parameters and returns the value of score .this is what i have, aparently this is wrong: class player{private: string name; int score; public: void player: : setname (string n){name =n; }void player: : setscore (int s){score = s; }string player: : getname (){return name; }int player: : getscore (){return score; }};
Answers: 2
image
Computers and Technology, 23.06.2019 09:30, kreshnikolloma
You wanted to look up information about alzheimer's, but you were unsure if it was spelled "alsheimer's" or "alzheimer's." which advanced search strategy would be useful? a) a boolean search b) using a wild card in your search c) trying different search engines d) doing a search for "alsheimer's not alzheimer's" asap. ill give brainlist.
Answers: 1
Do you know the correct answer?
Define an interface named Shape with a single method named area that calculates the area of the geom...

Questions in other subjects:

Konu
English, 29.06.2021 17:40