Java程序辅导

C C++ Java Python Processing编程在线培训 程序编写 软件开发 视频讲解

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439
 
 
  
 
  
1 
COMP9103   Software Development in Java         Tutorial and Lab 07 
OBJECT-ORINETED DESIGN 
The key topic for this week is Software Development procedure File IO.  
 
NOTE: Everyone is strongly encouraged to complete all the tutorials questions, lab exercises 
and homework!  
 
TASK 
1. Experience design and development procedure 
2. Practice File IO.  
 
 
LABORATORY EXERCISES 
Exercise1: Car class 
Consider the following Car class: 
public class Car { 
 
   private double speed; 
   private double accelerationPower; 
   private double brakePower; 
   private boolean acceleratorOn; 
   private boolean brakeOn; 
   private double position; 
   private String name; 
   private static double lowerSpeedLimit = 80.0; 
   private static double upperSpeedLimit = 110.0; 
  
   public Car(String n, double s, double p, double a, double b){ 
     name = n; 
     position = p; 
     accelerationPower = a; 
     brakePower = b; 
     speed = 0.0; 
     acceleratorOn = true; 
     brakeOn = false; 
   } 
  
  public double getPosition(){ 
     return position; 
  } 
  
  public double getSpeed(){ 
     return speed; 
  } 
  
  public String getName(){ 
    return name; 
  } 
 
  private boolean tooFast(){ 
    return (speed>upperSpeedLimit); 
  } 
  
  private boolean tooSlow(){ 
    return (speed