Question: Lab 4 Writing a triangle(Java) Due Date: 5/2/17 Lab 4 I would like you to write five classes. Each class will have a varying number
Lab 4 Writing a triangle(Java)




Due Date: 5/2/17 Lab 4 I would like you to write five classes. Each class will have a varying number of methods and they are described below, I have tried to give you as much information as you'd need to write each method. Let me know if you have any questions. Only one class will have your main) method, this is the Test class. After writing each method, I would like you to write at least on tests for each method in each cdass, to check its correctness. Each test should be written inside of main) Refer to the testing section to see how I'd like you to write your tests. You should write getters and setters for each member field in each class even though they are not stated as methods you need to write below. Writing getters and setters will help you test your classes. 1. Write a class called Rectangle. The Rectangle class will create objects that representa Rectangle. Following is the member fields and methods you will need to write. a. This class has two member fields: i. private double width ii. private double length b. Write two constructors for this class The first constructor takes no parameters, and sets width and length equal to 0 The second constructor takes two parameter, double width and double length, and sets the member fields equal to the corresponding parameter i. ii. c. Write two methods for this class: i. The first method is called area) 1. This method takes no parameters This method multiplies the two member fields together and returns the 2. 3. 1. This method returns a double ii. The second method is called perimeter() This method takes no parameters This method finds the perimeter using the two member fields and returns the result. This method return a double 2. 3. 2. Write a class called RightTriangle. The RightTriangle class will create objects that represent a RightTriangle. Following is the member fields and methods you will need to write a. This class has two member fields: i. private double base ii. private double height b. Write two constructors for this class The first constructor takes no parameters, and sets width and length equal to 0 The second constructor takes two parameter, double base and double height, and sets the member fields equal to the corresponding parameter i. ii. c. Write three methods for this class: i. The first method is called area) 1. This method takes no parameters 2. This method finds the area of this triangle and returns the result 3. The calculation for area of a triangle is base height
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
