Last week we received a test about Java Fundamentals and I wasn't able to finish it, I was wondering if someone could explain it to how to get it done.
The task was this:
Complete the program with collections, generics,... to get this output:
Room 11 has Hans Desmet as it's teacher
Felix De Vliegher follows basis
Koen Vanhoutte follows java
Serge Vereecke follows java
Freddy Himpe follows .net
Room 11 has Hans Desmet as it's teacher
There are 4 cursisten
Felix De Vliegher follows C++
Serge Vereecke follows java
Freddy Himpe follows .net
Alexandra Blondeel follows java
and this was given
public class Main { public static void main(String[] args) { Traject traject1 = new Traject("c++"); Traject traject2 = new Traject("java"); Traject traject3 = new Traject(".net"); Traject traject4 = new Traject("basis"); Cursist cursist1 = new Cursist("Felix" , "De Vliegher" , traject4); Cursist cursist2 = new Cursist("Koen" , "Vanhoutte," , traject2); Cursist cursist3 = new Cursist("Serge" , "Vereecke" , traject2); Cursist cursist4 = new Cursist("Freddy" , "Himpe" , traject3); Instructeur instructeur = new Instructeur("Hans","Desmet"); Lokaal lokaal = new Lokaal(11, instructeur); lokaal.add(cursist1); lokaal.add(cursist2); lokaal.add(cursist3); lokaal.add(cursist4); System.out.println(lokaal); cursist1.setTraject(traject1); Cursist cursist5 = new Cursist("Alexandra" , "Blondeel", traject2); lokaal.remove(cursist2); System.out.println(lokaal); } }
--- Update ---
So far I made these classes:
i think in class Lokaal is everything wrong but I have no idea how to fix it....
public class Lokaal extends Main { private int nr; private int aantalCursisten; public Lokaal(int nr, Cursist cursist, Traject traject){ setNr(nr); } public Lokaal(int nr, Instructeur instructeur){} public int getNr() { return nr; } private void setNr(int nr) { this.nr = nr; } public void aantalCursisten(int aantal){ aantalCursisten += aantal; } public void toevoegen(Cursist cursist){ } public void remove(Cursist cursist){ } }
public class Instructeur { public Instructeur(String naam, String familieNaam) { setNaam(naam); setFamilieNaam(familieNaam); } private String naam; private String familieNaam; public String getNaam(){ return naam; } public String getFamilieNaam(){ return familieNaam; } private void setFamilieNaam(String familieNaam){ this.familieNaam = familieNaam; } private void setNaam(String naam) { this.naam = naam; } }
public class Cursist { public Cursist(String naam, String familieNaam) { setNaam(naam); setFamilieNaam(familieNaam); } public Cursist(String naam, String familieNaam, Traject traject){} private String naam; private String familieNaam; public String getNaam() { return naam; } private void setNaam(String naam) { this.naam = naam; } public String getFamilieNaam() { return familieNaam; } private void setFamilieNaam(String familieNaam) { this.familieNaam = familieNaam; } public void setTraject(Traject traject) { } }