Hello,
I'm trying to figure out what I'm doing wrong here. For an assignment I need to get people with a VIP pass in the correct row when entering a Bakery.
Row 1 is for people with a VIP pass. However, that row can only take 10 people in line (after they remodel, it can take 15. But I'm not that for in the assignment yet). So if there are 10 people in row 1, the 11th should go to row 2.
In the code below, I get the people in the right row. However, if I want to add an 11th person with VIP pass, it should go to row 2, but with this piece of code it will go to row 1. I've been trying to change things, but that doesn't work.
What am I missing/doing wrong here?
Thanks for the help!
public class Bakery { // instance variables private String name; private int MaxInRow1; private ArrayList<Person> row1; //people with VIP pass private ArrayList<Person> row2; //people without VIP pass /** * Constructor for objects of class Bakery */ public Bakery (String name) { this.name = name; MaxInRow1 = 10; row1 = new ArrayList<Person> (); row2 = new ArrayList<Person> (); } public void enterBakery (Person name) // { if (name.hasVIPpass() == true) { int MaxInRow1 = 0; if (MaxInRow1 < 10) { row1.add(name); } else { row2.add(name); } } else { row2.add(name); } }