1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
|
public class Voiture extends Vehicule
{
// instance variables - replace the example below with your own
private boolean diesel;
private int place;
private int prix;
private int volumeChargement;
/**
* Constructor for objects of class Voiture
*/
public Voiture ()
{
place=0;
prix=0;
volumeChargement=0;
diesel=false;
}
public Voiture (boolean d, int p, int pr, int v)
{
diesel=d;
if (p>=4)
{place=4;}
else
{place=p;}
prix=pr;
if (v<100)
{volumeChargement=100;}
else
{volumeChargement=v;}
}
public boolean getdiesel()
{
return diesel;
}
public int getplace()
{
return place;
}
public int getprix()
{
return prix;
}
public int getvolumeChargement()
{
return volumeChargement;
}
public void setdiesel( boolean d)
{
diesel=d;
}
public void setplace (int p)
{
place=p;
}
public void setprix (int pr)
{
prix=pr;
}
public void setvolumeChargement(int c)
{
volumeChargement=c;
}
public int getVehicule ()
{
int x = getplace() + getprix() + getvolumeChargement();
return x;
}
public String toString()
{
String s = new String ();
s = s+getdiesel()+" "+getplace()+" " +getprix()+ " " + getvolumeChargement();
return s;
}
public void affiche()
{
System.out.print( "diesel: " + getdiesel()+", "+"nombres de places: " +getplace()+", " +"prix: "+getprix()+ ", " +"Volume: " +getvolumeChargement());
}
} |
Partager