文档详情

Java面向对象编程练习题(国外英文资料).doc

发布:2017-06-06约1.55万字共19页下载文档
文本预览下载声明
Java面向对象编程练习题(国外英文资料) Guess Numbers game  A class A has A member variable v  has an initial value of 100. Define A class  on A The member variable of the class is going to guess. If big big  is small for tooltips. Is equal to the suggestion Measure success.  exercises 02 】. The members of the class variables Please define a kind of Attribute  speed (speed)  volume (size), and so on Methods  mobile (move ())  set speed (setSpeed (int speed))  accelerated speedUp (), slow down SpeedDown () and so on. Finally in test class of Vehicle in the main () object instantiates a transport  and through the way to it Initial speed, the size of the value of  and through printed. Another method of accelerating   call to slow down to speed Degrees change. Class member variables and methods, construction methods In the program to operating time   often but there was no time data types. So we can  To achieve a class time  to meet the needs of the application. Define class called MyTime should have three integer member of   when  the adrenaline-charged   points  minute   seconds  second   in order to guarantee the security of data  the three member variables should be declared as private. For MyTime class definition  constructor for creating object initialization member variables. Redefinition  diaplay method is used to print time information. For MyTime  classes to add the following methods AddSecond (int SEC) AddMinute (int min) AddHour (int hou) SubSecond (int SEC) SubMinute (int min) SubHour (int hou) Adding and subtracting the time, minutes and seconds respectively. [practice problem] 04. Construction method Write a Java program  simulation simple calculator. Define the called Number class  two integer data members n1 and n2  should be declared as private. Ed Write a constructor   give n1 and n2 initial values for the class definition and  addition , subtract  subtration , By  multiplication  and divide  division   respectively for t
显示全部
相似文档