Hi can you please help me with the following code program as I am new to java.
Step1: define the interface named Ashape
write an interface called Ashape that defines:
double DEFAULT_SIZE equal to 1.0 [by default it is constant]
method calcPerim() that returns a double equal to the perimeter of the shape.
step2: write the classes ATriangle and ARectangle
Atriangle class has three double instance variables; side1, side2 and hypot.
ARectangle class has two double instance variables; width and height.
both classes have the following attributes and additional methods:
Have a constructor that has a parameter to initialize each instance variable.
have a default constaructor to initialize each instance variable to the value of DEFAULT_SIZE.
Have a tostring() method which prints the class name [Triangle or Rectangle] attributes wit text identifying them, and the "perimeter" with its value (see sample output)
step3 write the main class TestShapes
Define four objects:
Triangle has sides 3,4,5
Rectangle with the width of 6 and the height of 8
Triangle object created by the default constructor
Rectangle object created by the default constructor
Print the four method use the toString() method
Step4 Using the interface constants:
In the TestShapes class, print DEFAULT_SIZE five times as shown in the sample output below:
1. using AShape interface name
2. using ATriangle class name
3. using ATriangle object name
4. using ARectangle object
Triangle: side1 = 1.0 side2 = 1.0 hypot = 1.0 perimeter = 3.0
Rectangle: length = 1.0 width = 1.0 perimeter = 4.0
Triangle: side1 = 3.0 side2 = 4.0 hypot = 5.0 perimeter = 12.0
Rectangle: length = 8.0 width = 6.0 perimeter = 28.0
Accessing Constant in AShape interface
Access via Ashape interface: 1.0
Access via Atriangle class: 1.0
Access via Atriangle object: 1.0
Access via Arectangle object:1.0
Access via Arectangle object: 1.0
Can you please tell me although TestShapes does not inplement the AShape interface why we can access AShape.DEFAULT_SIZE in the TestShape class?
Thank you sooo much