H10 Watersportclub met zeil en motorboten Flashcards

(9 cards)

1
Q

Club.addReservatie(): Adds a new Reservatie to the reservaties list. (Lid lid, Boot boot, int aantalUren) First, it checks if the Lid exists (and adds them if not) and if the Boot exists. Give also error.

A

public void addReservatie(Lid lid, Boot boot, int aantalUren) {
if (!bestaatLid(lid.getNaam())) {
leden.add(lid);
}
if (bestaatBoot(boot.getNaam())) {
reservaties.add(new Reservatie(lid, boot, aantalUren));
} else {
System.out.println(“reservatie van “ + boot.getNaam() + “ voor “ + lid.getNaam() + “ ging niet door.”);
}
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Main.main(): Creates Lid, Boot (both Motorboot and Zeilboot), and Club objects. It adds boats to the club and creates a couple of reservations. This method demonstrates object creation and method calls to set up the simulation. Write the Java code.

A

public class Main {
public static void main(String[] args) {
Lid mieke = new Lid(“Mieke”, “0477889966”, 10);
Lid maarten = new Lid(“Maarten”, “0499887744”, 0);

    Boot marieLouise = new Motorboot("Marie-Louise", 50, true, false);
    System.out.println(marieLouise.getDetail());
    Boot titanic = new Zeilboot("Titanic", 75, true, true);
    System.out.println(titanic.getDetail());

    Club club = new Club("haventje");
    club.addBoot(marieLouise);
    club.addBoot(titanic);

    club.addReservatie(mieke, marieLouise, 6);
    club.addReservatie(maarten, titanic, 2);
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Club.bestaatBoot(): Checks if a boat with the given name exists in the boten list. This method iterates through the boten list using an Iterator and a while loop, checking each boat’s name. Write the Java code.

A

private boolean bestaatBoot(String naamBoot) {
Iterator<Boot> it = boten.iterator();
boolean found = false;
while (it.hasNext() && !found) {
Boot boot = it.next();
if (boot.getNaam().equals(naamBoot)) {
found = true;
}
}
return found;
}</Boot>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Club.bestaatLid(): Checks if a member with the given name exists in the leden list. This method iterates through the leden list using an Iterator and a while loop, checking each member’s name. Write the Java code.

A

private boolean bestaatLid(String naamLid) {
Iterator<Lid> it = leden.iterator();
boolean found = false;
while (it.hasNext() && !found) {
Lid lid = it.next();
if (lid.getNaam().equals(naamLid)) {
found = true;
}
}
return found;
}</Lid>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Club.getLijstReservatiesBoot(): Generates a string containing a list of reservations for a specific boat (given bootNaam). It uses a for loop to iterate through the reservaties list and an if statement to check the boat’s name. Write the Java code.

A

public String getLijstReservatiesBoot(String bootNaam) {
String s = “Lijst reservaties voor “ + bootNaam + “\n”;
for (Reservatie reservatie : reservaties) {
if (reservatie.getBoot().getNaam().equals(bootNaam)) {
s += “reservatie door “ + reservatie.getLid().getNaam() + “ voor “ + reservatie.getAantalUren() + “ uren.\n”;
}
}
return s;
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Club.getTotaalTeBetalenLid(): Calculates the total amount a member (given lidnaam) has to pay for all their reservations. This method uses a for loop to iterate through the reservaties list and an if statement to select reservations for that member. Write the Java code.

A

public double getTotaalTeBetalenLid(String lidnaam) {
double totaal = 0.0;
for (Reservatie reservatie : reservaties) {
if (reservatie.getLid().getNaam().equals(lidnaam)) {
totaal += reservatie.teBetalen();
}
}
return totaal;
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Club.getBotenDetails(): Returns a String containing the details of all boats. This method makes use of a enhanced for loop. Write the Java code.

A

public String getBotenDetails() {
String s = “Boten in “ + naam + “\n”;
for (Boot boot : boten) {
s += boot.getDetail() + “\n”;
}
return s;
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Club.getLedenDetails(): Returns a String containing the details of all Leden. This method makes use of a enhanced for loop. Write the Java code.

A

public String getLedenDetails() {
String s = “Leden in “ + naam + “\n”;
for (Lid lid : leden) {
s += lid.getDetail() + “\n”;
}
return s;
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Club.getReservatiesDetails(): Returns a String containing the details of all reservaties. This method makes use of a enhanced for loop. Write the Java code.

A

public String getReservatiesDetails() {
String s = “Reservaties in “ + naam + “\n”;
for (Reservatie reservatie : reservaties) {
s += reservatie.getDetail() + “\n”;
}
return s;
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly