Java class and object 1, java object
Write A Java application, which has three classes: Lader, Circle, and primary class. The specific requirements are as follows: The Lader class has the upper bottom, lower bottom, high, and area attributes of the double type, and has the function of returning the area, including a constructor to initialize the bottom, bottom, and height. The Circle class has the radius, circumference, and area attributes of the double type, and has the function of returning perimeter and area, including a constructor to initialize the radius. Main Class A is used to test the functions of class Lader and class Circle.
Trapezoid type:
1 double shangdi; 2 double xiadi; 3 double heiht; 4 double S; 5 6 Lader (double sd, double xd, double g) 7 {8 S = (sd + xd) * g/2; 9 System. out. println ("Trapezoid area S =" + S); 10}
Circle:
1 double r; 2 double C; 3 double Sr; 4 double PI = 3.14; 5 6 Circle (double r) 7 {8 C = 2 * PI * r; 9 System. out. println ("circle circumference C =" + C); 10 Sr = PI * r; 11 System. out. println ("area Sr =" + Sr); 12}
Test:
1 Lader Tx1 = new Lader (2.2, 3.5, 4); 2 Circle Yuan1 = new Circle (5.5 );
Result: