Skip to content
Snippets Groups Projects
Commit 2766d976 authored by Nicolas Eckman's avatar Nicolas Eckman :hushed:
Browse files

CTP2022

parent bd89ef75
Branches main
No related tags found
No related merge requests found
package tpOO.ctp2022;
import java.time.LocalDate;
import java.time.temporal.ChronoUnit;
public enum AgeCategory {
NURSELING(1.5), LITTLE(1.0), GROWN(0.8);
private final double QUOTA;
public double getQuota(){
return QUOTA;
}
private AgeCategory(double quota){
this.QUOTA = quota;
}
public static AgeCategory getInstance(LocalDate date){
int i = (int)date.until(LocalDate.now(),ChronoUnit.MONTHS);
if (i<8) return AgeCategory.NURSELING;
if (i<18) return AgeCategory.LITTLE;
else return AgeCategory.GROWN;
}
}
\ No newline at end of file
package tpOO.ctp2022;
import java.time.LocalDate;
public class Infant {
private final String FORENAME;
private String name;
private final LocalDate BIRTH;
private AgeCategory category;
Infant (String forename, String name, LocalDate birth, AgeCategory category){
this.FORENAME = forename;
this.name = name;
this.BIRTH = birth;
this.category = category;
}
Infant (String forename, String name, LocalDate birth){
this.FORENAME = forename;
this.name = name;
this.BIRTH = birth;
this.category = AgeCategory.getInstance(birth);
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment