package base;

import housing.interfaces.Renter;
import housing.roles.RenterRole;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;

import city.gui.CityPanel;
import base.interfaces.Person;
import base.interfaces.Role;

public class ConfigParser {

	private static ConfigParser instance = null;

	public void readFileCreatePersons() throws FileNotFoundException {
		Scanner scanner = new Scanner(getClass().getResourceAsStream("/config.txt"));
		CityPanel citypanel = CityPanel.getInstanceOf();
		while (scanner.hasNext()) {
			String mName = scanner.next();
			Person newPerson = new PersonAgent("mName");
			Double mStartcash = Double.parseDouble(scanner.next());
			newPerson.setCash(mStartcash);
			String mStartingRole = scanner.next();
			if (mStartingRole.equals("Renter")) {
				Renter newRenterRole = new RenterRole();
				newPerson.addRole((Role) newRenterRole);
			}
			//TODO: add handling for all the other possible roles
			synchronized (newPerson) {
				citypanel.masterPersonList.add(newPerson);
			}
		}

	}

	private ConfigParser() {
	}

	public static ConfigParser getInstanceOf() {
		if (instance == null) {
			instance = new ConfigParser();
		}
		return instance;
	}

}

@@ -27,25 +27,118 @@
 ing.
-interfaces.Renter
+House;%0Aimport housing.interfaces.Landlord;%0Aimport housing.interfaces.Renter;%0Aimport housing.roles.LandlordRole
 ;%0Aim
@@ -173,29 +173,8 @@
 e;%0A%0A
-import java.io.File;%0A
 impo
@@ -238,35 +238,8 @@
 r;%0A%0A
-import city.gui.CityPanel;%0A
 impo
@@ -294,16 +294,136 @@
 s.Role;%0A
+import city.gui.CityPanel;%0A%0A/*%0A * Reads in a config file filled with new people to instantiate%0A * @author David Carr%0A */
 %0Apublic 
@@ -796,15 +796,13 @@
 ent(
-%22
 mName
-%22
 );%0A%09
@@ -935,16 +935,218 @@
 next();%0A
+%09%09%09if (mStartingRole.equals(%22Landlord%22)) %7B%0A%09%09%09%09LandlordRole newLandlordRole = new LandlordRole();%0A%09%09%09%09for (int i=0; i%3C4; i++) %7B%0A%09%09%09%09%09newLandlordRole.mHousesList.add(new House(5, 5, 60));%09%09%09%09%0A%09%09%09%09%7D%0A%09%09%09%7D%0A
 %09%09%09if (m
@@ -1188,16 +1188,20 @@
 %09%09Renter
+Role
  newRent

add more roles to configparser