You will create a class called Square. Length will represent the length of one side which is an integer. You should create the constructor, an instance variable, a getter method for the length of a side, a getArea method and a toString method. The area of a square = length * length. Your toString method should be written such that it would return a String of the form "Square with side length: 8” (if the side length was 8) public class Square { //create one instance variable called length //create the constructor with one parameter //create your getter method to get the length of one side with return type integer //create the getArea method with return type integer //create the toString method }
You will create a class called Square. Length will represent the length of one side which is an integer.
You should create the constructor, an instance variable, a getter method for the length of a side, a getArea method and a toString method. The area of a square = length * length.
Your toString method should be written such that it would return a String of the form
"Square with side length: 8” (if the side length was 8)
public class Square |
{ |
//create one instance variable called length |
//create the constructor with one parameter |
//create your getter method to get the length of one side with return type integer |
//create the getArea method with return type integer |
//create the toString method |
} |
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 1 images