Home > Back-end >  Java topics
Java topics

Time:09-23

Create graphics class TuXing, punctuated with attributes and methods, and properties: long, wide, the method of pupil method: to calculate the area of

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 answer

CodePudding user response:

dddddd

CodePudding 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
  • Related