Have brought no-parameter constructor and constructor with no parameters, create rectangle ChangFangXing derived class, create a square ZhengFangXing derived class, two classes are inherited from the graphics, writing test cases
Create a rectangle object new ChangFangXing (3, 4), its width is 3 and 4, direct assignment also create a square object, its length is 5, direct assignment respectively calculate the area of the rectangle object of pupil square object
CodePudding user response:
Very urgent, please answerCodePudding user response:
ddddddCodePudding user response:
Public abstract class TuXing {
Private int length;
Private int width;
Public TuXing (int length, int width) {
This. Length=length;
this.width=width;
}
Public abstract void girth ();
Public abstract void area ();
}
/* *
* rectangle class
*/
The class ChangFangXing extends TuXing {
Public ChangFangXing (int length, int width) {
Super (length, width);
}
/* *
* calculate circumference*/
@ Override
Public void girth () {
}
/* *
* calculation area*/
@ Override
Public void area () {
}
}
/* *
* square*/
The class ZhengFangXing extends TuXing {
Public ZhengFangXing (int length, int width) {
Super (length, width);
}
/* *
* calculate circumference*/
@ Override
Public void girth () {
}
/* *
* calculation area*/
@ Override
Public void area () {
}
}
Calculate the pupil write it by yourself