package mcp;

import processing.core.*;
import java.util.regex.Pattern;
import java.util.regex.Matcher;

public class Game {
	String name;
	PImage image;
	String path;
	PApplet parent;
	static final String GAME_RULE = "'([-_a-zA-Z0-9. ]+)' '([-_a-zA-Z0-9. /]+)' '([-_a-zA-Z0-9. /]+)'";
	static final Pattern GAME_PATTERN = Pattern.compile(GAME_RULE);

	public Game(PApplet parent, String name, String path, String imagePath) {
		this.parent = parent;
		this.name = name;
		this.path = path;
		this.image = parent.loadImage(imagePath);
	}

	public void run() {
		parent.println("Running game " + name);
		parent.exit();
	}

	public static Game fromString(PApplet parent, String line) {
		System.out.println("parsing line");
		System.out.println(line);
		Matcher lineMatcher = GAME_PATTERN.matcher(line);

		if (!lineMatcher.matches()) {
			throw new IllegalArgumentException("The inputted line was malformed.\n" + line);
		}

		String name = lineMatcher.group(1);
		String path = lineMatcher.group(2);
		String image = lineMatcher.group(3);

		Game g = new Game(parent, name, path, image);
		System.out.println(g);
		return g;
	}

	public String toString() {
		return String.format("Game [name=%s path=%s image=%s]", name, path, image);
	}
}

@@ -682,74 +682,8 @@
 ) %7B%0A
-%09%09System.out.println(%22parsing line%22);%0A%09%09System.out.println(line);%0A
 %09%09Ma
@@ -1020,33 +1020,8 @@
 e);%0A
-%09%09System.out.println(g);%0A
 %09%09re

remove printing from game class