class Person { private String firstName; private String middleName; private String lastName; private int age; private double height; private double weight;
Person(String firstName, String lastName, int age, double height, double weight) { this.firstName = firstName; this.lastName = lastName; this.age = age; this.height = height; this.weight = weight; }
Person(String firstName, String middleName, String lastName, int age, double height, double weight) { this(firstName, lastName, age, height, weight); this.middleName = middleName; }
public String fullName() { if (this.middleName == null) { return this.firstName + " " + this.lastName; } else { return this.firstName + " " + this.middleName + " " + this.lastName; } }
public void printData() { System.out.println ("nom est" + this.fullName () + "est"); System.out.println ("age is" + this.age + "years old"); System.out.println ("hauteur est" + this.height + "m"); System.out.println ("Weight is" + this.weight + "kg"); System.out.println ("IMC est" + Math.round (this.bmi ()) + ""); }
public double bmi() { return this.weight / this.height / this.height; }
// Veuillez réécrire les deux suivants avec une méthode public void buy(Vehicle vehicle){ vehicle.setOwner(this); } }