Hello,
I don't know why the 6th step not work
Someone can help me
package fr.codegym.task.task15.task1505;
import java.util.ArrayList;
import java.util.List;
/*
POO : Corriger les problèmes d'héritage
*/
public class Solution {
public static interface LivingPart {
Object containsBones();
}
public static class BodyPart implements LivingPart {
protected static final String YES = "Yes";
protected static final String NO = "No";
private String name;
public BodyPart(String name) {
this.name = name;
}
@Override
public Object containsBones() {
return YES;
}
@Override
public String toString() {
return containsBones().equals(YES) ? name + " contient des os " : name + " ne contient pas d'os";
}
}
public static class Finger extends BodyPart {
private boolean isArtificial;
public Finger(String name, boolean isArtificial) {
super(name);
this.isArtificial = isArtificial;
}
@Override
public Object containsBones() {
return (super.containsBones().equals(YES) && !isArtificial) ? YES : NO;
}
}
public static void main(String[] args) {
printlnFingers();
printlnBodyParts();
printlnLivingParts();
}
private static void printlnLivingParts() {
System.out.println(new BodyPart("Main").containsBones());
}
private static void printlnBodyParts() {
List<BodyPart> bodyParts = new ArrayList<BodyPart>(5);
bodyParts.add(new BodyPart("Main"));
bodyParts.add(new BodyPart("Jambe"));
bodyParts.add(new BodyPart("Tête"));
bodyParts.add(new BodyPart("Corps"));
System.out.println(bodyParts.toString());
}
private static void printlnFingers() {
List<Finger> fingers = new ArrayList<Finger>(5);
fingers.add(new Finger("Pouce", true));
fingers.add(new Finger("Index", true));
fingers.add(new Finger("Majeur", true));
fingers.add(new Finger("Annulaire", false));
fingers.add(new Finger("Auriculaire", true));
System.out.println(fingers.toString());
}
}