java eighth job - inherited

 

I, entitled

 

Writing an application, create a rectangle class, a class with a long, wide two member variables and methods find the circumference. Then create a subclass of class ------ square rectangle class, find the area method of class definitions, methods of overwriting find the circumference. In the main class, the input side length of a square, a square object is created, the square area and perimeter requirements. (Note: all classes are in a package)

 

rectangle.java

Class defines a rectangular long length, broad width, and a method of seeking a rectangular perimeter

 

square.java

Square class defines two member variables sperimeter, getarea. Perimeter and area of ​​the square and methods seek

 

 

 Class main part - to create objects, the input side length, the calling method find the area perimeter.

 

Guess you like

Origin www.cnblogs.com/zky2/p/11580603.html