H8 Studieprogramma Flashcards
isGeslaagd() (Studieprogramma): Determines if a student has passed all courses in their program. Write the Java code for this method.
public boolean isGeslaagd() {
for (Vak vak : getStudieprogramma()) {
if (!vak.isGeslaagd()) {
return false;
}
}
return true;
}
getRapport() (Studieprogramma): Generates a formatted report of a student’s results. Write the Java code for this method, including their name, overall pass/fail status, and course details, matching the provided examples.
Toont studentgegevens, zegt of de student geslaagd is of niet, en geeft een overzicht van alle vakken.
public String getRapport() {
String afdruk = student.getDetail();
if (isGeslaagd()) {
afdruk += “ GESLAAGD\n”;
} else {
afdruk += “ NIET GESLAAGD\n”;
}
for (Vak vak : getStudieprogramma()) {
afdruk += vak.getDetail() + “\n”;
} return afdruk; }
addVak() (Studieprogramma): Adds a Vak object to the student’s study program. “Als studieprogramma het vak met deze vakcode nog niet bevat, dan… (containskey) Write the Java code for this method, preventing duplicate courses based on vakcode.
public void addVak(Vak v) {
if (!this.studieprogramma.containsKey(v.getVakcode())) {
this.studieprogramma.put(v.getVakcode(), v);
}
}
removeVak() (Studieprogramma): Removes a Vak object from the student’s study program. Write the Java code for this method, using the vakcode to identify the course.
public void removeVak(String vakcode) {
studieprogramma.remove(vakcode);
}
vindVak() (Studieprogramma): Finds and returns a Vak object from the student’s study program. Write the Java code for this method, using the vakcode to locate the course.
public Vak vindVak(String vakcode) {
return studieprogramma.get(vakcode);
}
getStudieprogramma() (Studieprogramma): Returns a List of Vak objects representing the student’s study program. Write the Java code for this method.
public List<Vak> getStudieprogramma() {
List<Vak> studiepgm = new ArrayList<>();
studiepgm.addAll(studieprogramma.values());
return studiepgm;
}</Vak></Vak>
bv
TINF1234 Programmeren 6 SP 14/20 credit behaald
Schrijf een methode getDetail() die een string teruggeeft met vakinfo: vakcode, naam, studiepunten (met ‘SP’), en indien van toepassing de score (score/MAX_SCORE). Voeg toe: ‘credit behaald’ als geslaagd, ‘niet geslaagd’ als score < slaaggrens, of ‘niet deelgenomen’ als er geen score is.
public String getDetail() {
String afdruk = vakcode + “ “ +
naam + “ “ +
studiepunten + “ SP “;
if (score != null) {
afdruk += score + “/” + MAX_SCORE;
}
if (isGeslaagd()) {
afdruk += “ credit behaald”;
} else if (score != null) {
afdruk += “ niet geslaagd”;
} else {
afdruk += “ niet deelgenomen”;
}
return afdruk;
}
setScore controleer of Integer score tussen MIN_SCORE en MAX_SCORE ligt pas dan mag de score ingevoerd worden anders geef een waarschuwing en maak de score leeg ANDERS laat de score ingevoerd
public void setScore(Integer score) {
if (score != null) {
if (MIN_SCORE <= score && score <= MAX_SCORE) {
this.score = score;
} else {
System.out.println(“Waarde moet tussen “ + MIN_SCORE + “ en “ + MAX_SCORE + “ liggen. “);
this.score = null;
}
} else {
this.score = score;
}
}
schrijf methode isGeslaagd() controleer , als er iets ingevuld staat van de score moet je zeker de score teruggeven dat boven of gelijk is aan SLAAG_SCORE anders geef je onwaar terug
public boolean isGeslaagd() {
if (score != null) {
return score >= SLAAG_SCORE;
} else {
return false;
}
}