package Review;

import java.util.*;

public class Table {
	private ArrayList people;
	private int maxNumberPeople;
	
	public Table(int theMaxNumberPeople) {
		people = new ArrayList();
		maxNumberPeople = theMaxNumberPeople;
	}
	
	public void addPerson(String name) {
		if (people.size() < maxNumberPeople) {
			people.add(name);
		}		
	}
	
	public void removePerson(String name) {
		people.remove(name); 
	}
	
	public String[] getPeople() {
		String[] array = new String[people.size()];
		
		people.toArray(array);
		return array;
	}
	
	public int getNumberOfPeople() {
		return people.size();
	}
	
	public boolean hasPerson(String name) {
		Iterator iterator = people.iterator();
		String nextName;
		boolean found = false;
		
		while(iterator.hasNext()) {
			nextName = (String)iterator.next();
			if (nextName.equals(name)) {
				found = true;
				break;
			}
		}
		
		return found;
	}
}