package com.pm.server.player;

import java.util.List;

import org.springframework.stereotype.Repository;

@Repository
public class GhostRepositoryImpl implements GhostRepository {

	private List<Ghost> ghosts;

	public Ghost getGhostById(Integer id) {

		for(Ghost ghost : ghosts) {
			if(ghost.getId() == id) {
				return ghost;
			}
		}
		return null;

	}

	public List<Ghost> getAllGhosts() {
		return ghosts;
	}

	public void addGhost(Ghost ghost) throws Exception {

		if(getGhostById(ghost.getId()) != null) {
			ghosts.add(ghost);
		}
		else {
			throw new IllegalArgumentException(
				"addGhost() was given an id belonging to a ghost which is " +
				"already in the registry."
			);
		}

	}

}
@@ -24,16 +24,44 @@
 layer;%0A%0A
+import java.util.ArrayList;%0A
 import j
@@ -232,16 +232,80 @@
 hosts;%0A%0A
+%09GhostRepositoryImpl() %7B%0A%09%09ghosts = new ArrayList%3CGhost%3E();%0A%09%7D%0A%0A
 %09public 

Initialize ghost list in GhostRespository