Vous êtes sur la page 1sur 4

package tp2 ;

import java.util.ArrayList ;
import java.util.Scanner;

public class Véhicule {


private String marque ;
private String maison ;
private String couleur ;
private int nbr_passager ;
private Date date_creation ;
private int matricule ;
private int nbr_rowe ;
private ArrayList <Integer> nbr_rowes ;
private int puissance ;

// ---------------------------------------

public Véhicule() {}

public Véhicule(String marque, String maison, String couleur, int nbr_passager,


Date date_creation, int matricule,
int nbr_rowe, ArrayList<Integer> nbr_rowes, int puissance) {
super() ;
this.marque = marque ;
this.maison = maison ;
this.couleur = couleur ;
this.nbr_passager = nbr_passager ;
this.date_creation = date_creation ;
this.matricule = matricule ;
this.nbr_rowe = nbr_rowe ;
this.nbr_rowes = nbr_rowes ;
this.puissance = puissance ;
}

// ----------------------------------------

public String getMarque() {


return marque ;
}

public void setMarque(String marque) {


this.marque = marque ;
}

public String getMaison() {


return maison ;
}

public void setMaison(String maison) {


this.maison = maison ;
}

public String getCouleur() {


return couleur ;
}

public void setCouleur(String couleur) {


this.couleur = couleur ;
}

public int getNbr_passager() {


return nbr_passager ;
}

public void setNbr_passager(int nbr_passager) {


this.nbr_passager = nbr_passager ;
}

public Date getDate_creation() {


return date_creation ;
}

public void setDate_creation(Date date_creation) {


this.date_creation = date_creation ;
}

public int getMatricule() {


return matricule ;
}

public void setMatricule(int matricule) {


this.matricule = matricule ;
}

public int getNbr_rowe() {


return nbr_rowe ;
}

public void setNbr_rowe(int nbr_rowe) {


this.nbr_rowe = nbr_rowe ;
}

public ArrayList<Integer> getNbr_rowes() {


return nbr_rowes ;
}
public void setNbr_rowes(ArrayList<Integer> nbr_rowes) {
this.nbr_rowes = nbr_rowes ;
}

public int getPuissance() {


return puissance ;
}

public void setPuissance(int puissance) {


this.puissance = puissance ;
}

// ----------------------------------------

public float claculer_puissance() {


float y = (float)((this.puissance * 10 *10 *10) * 1.4) ;
return y ;
}

// ----------------------------------------
public Date clauler_periode(Date date_creation,Date now) {
Date period = new Date(0,0,0) ;

int d,m,y;
if (now.getJour() >= date_creation.getJour() ) {

d = now.getJour() - date_creation.getJour() ;
if ( now.getMois() >= date_creation.getMois() ) {
m = now.getMois() - date_creation.getMois() ;
y = now.getAnnee()- date_creation.getAnnee() ;
}
else {
m = (12 - date_creation.getMois()) + now.getMois() ;
y = (now.getAnnee()- date_creation.getAnnee() )-1 ;

}
}
else {
d = (30 - date_creation.getJour()) + now.getJour() ;
if ( now.getMois() >= date_creation.getMois() ) {
m = (now.getMois() - date_creation.getMois() )- 1 ;
y = now.getAnnee()- date_creation.getAnnee() ;
}
else {
m = ((12 - date_creation.getMois()) + now.getMois()) -1 ;
y = (now.getAnnee()- date_creation.getAnnee() )-1 ;

}
m = now.getMois() - date_creation.getMois() ;
period.setJour(d) ;
period.setMois(m) ;
period.setAnnee(y) ;
return period ;
}

public Date creation (Date d) {

Date creation = new Date();

Scanner main = new Scanner(System.in) ;

System.out.println("entrez Jour ") ;


creation.setJour(main.nextInt()) ;
int j =creation.getJour() ;

while( (j < 1 ) || (j > 31)) {


System.out.println("error veuilliez saissir le jour correct") ;
creation.setJour(main.nextInt()) ;
j =creation.getJour() ;
}

System.out.println("entrez Mois ") ;


creation.setMois(main.nextInt()) ;
int mo = creation.getMois() ;
while( (mo < 1 ) || (mo > 12)) {
System.out.println("error veuilliez saissir mois correct") ;
creation.setMois(main.nextInt()) ;
mo = creation.getJour() ;
}

System.out.println("Entrez Anne ") ;


creation.setAnnee(main.nextInt()) ;
int a = creation.getAnnee() ;

while(( a < 0 ) && ( a > 2023 ) ) {


System.out.println("error veuilliez saissir la annné correcte") ;
creation.setAnnee(main.nextInt()) ;
a = creation.getAnnee() ;
}
d = creation;

return d;
}
}

Vous aimerez peut-être aussi