java object-oriented exercises, integrated use: encapsulation, inheritance, polymorphism

 

A car rental company's rental cars and rental vehicles as follows: 
1. The car 
	Audi Q7 600 yuan / day 
	BMW X7 700 yuan / day 
	Mercedes-Benz G 800 large / day 

2 buses 
	less than or equal 16, 800 yuan / day 
	greater than 16, 1200 / day 



a step objects designed for 
1, the analysis needs 
	to find a noun (class attributes) 
		brand, model (sedan), license plate number, date of rent (constant, you can write to die in the program), number of seats (buses) 

	find verb (method) 
		calculation of rent 

2, class design 
parent: 
	brand, license plate number 

subclass 
	car: model 
	bus: The number of seats 

car rental management class 
	entrance and system interface 


3, optimization 
	car (the parent class, abstract class): calculate rent -> abstract method 


II summarizes the 
  object-oriented: encapsulation, inheritance, polymorphism

  

Answer:

 

Guess you like

Origin www.cnblogs.com/uncleyong/p/12580618.html