/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package oopcoy1;
class Motorcycle{
/**
*
* @author hadiid
*/
double speed;
int capacity;
double fuel;
public Motorcycle(){
System.out.println("Motorcycle object is created...");
}
public Motorcycle (double f){
fuel =f;
System.out.println("Motorcycle object is created with"+fuel+"fuel");
}
public void accelerated (double a, int t, int cpc){
speed = a*t;
capacity = cpc;
if (speed>150){
speed = 150;
System.out.println("Speed is maximum ...");}
if (capacity > 150){
capacity = 150;
System.out.println("Capacity is maximum...");}
fuel = fuel-0.001*a*t;
System.out.println("Speed ="+speed);
System.out.println("Capacity ="+capacity);}
public String GetInfo(){
String tmp = "Motorcycle status=\n";
tmp=tmp + "Speed ="+speed;
tmp = tmp +"fuel="+fuel;
tmp = tmp +"capacity ="+capacity;
return tmp;
}
public double getSpeed (){return speed;}
public int getCapacity() {return capacity;}
public void setFuel(double f)
{
if (f<=1000){
fuel=fuel+f;
}
else
System.out.println("Fuel over speed...");
}
}
public class Oopcoy1 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
Motorcycle myMotorcycle = new Motorcycle(50);
myMotorcycle.accelerated (5,50,100);
System.out.println("Now Speed is"+myMotorcycle.getSpeed());
System.out.println("Now capacity is"+myMotorcycle.getCapacity());
myMotorcycle.GetInfo();
myMotorcycle.setFuel(150);
myMotorcycle.GetInfo();
}
}