Biblioteca Java - Rev 32

Subversion Repositories:
Rev:

package exemple.reflexie.app;

/**
 *
 * @author Mihai Hulea mihai.hulea@aut.utcluj.ro
 */

public class Car {
    private int maxSpeed = 0;
    private int crtSpeed = 0;
   
    public Car(){
        maxSpeed = 180;
    }
   
    public void accelerate(){
        if(crtSpeed<maxSpeed){
            crtSpeed++;
            System.out.println("Car accelerate to "+crtSpeed+" km/h");
        }else
            System.out.println("Car top speed "+crtSpeed+".Speed limit reached km/h");
    }
   
    private void setSpeedLimit(Integer x){
        maxSpeed = x;
    }
   
    public int getCarMaxSpeed(){
        return maxSpeed;
    }
   
    public String toString(){
        return "[Car max speed="+maxSpeed+"]";
    }
}