package mcp;

import processing.core.*;

public class Game {
	String name;
	PImage image;
	String path;
	PApplet parent;

	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();
	}
}

@@ -32,16 +32,80 @@
 .core.*;
+%0Aimport java.util.regex.Pattern;%0Aimport java.util.regex.Matcher;
 %0A%0Apublic
@@ -177,16 +177,182 @@
  parent;
+%0A%09static final String GAME_RULE = %22'(%5B-_a-zA-Z0-9. %5D+)' '(%5B-_a-zA-Z0-9. /%5D+)' '(%5B-_a-zA-Z0-9. /%5D+)'%22;%0A%09static final Pattern GAME_PATTERN = Pattern.compile(GAME_RULE);
 %0A%0A%09publi
@@ -595,16 +595,16 @@
  name);%0A
-
 %09%09parent
@@ -614,11 +614,628 @@
 it();%0A%09%7D
+%0A%0A%09public static Game fromString(PApplet parent, String line) %7B%0A%09%09System.out.println(%22parsing line%22);%0A%09%09System.out.println(line);%0A%09%09Matcher lineMatcher = GAME_PATTERN.matcher(line);%0A%0A%09%09if (!lineMatcher.matches()) %7B%0A%09%09%09throw new IllegalArgumentException(%22The inputted line was malformed.%5Cn%22 + line);%0A%09%09%7D%0A%0A%09%09String name = lineMatcher.group(1);%0A%09%09String path = lineMatcher.group(2);%0A%09%09String image = lineMatcher.group(3);%0A%0A%09%09Game g = new Game(parent, name, path, image);%0A%09%09System.out.println(g);%0A%09%09return g;%0A%09%7D%0A%0A%09public String toString() %7B%0A%09%09return String.format(%22Game %5Bname=%25s path=%25s image=%25s%5D%22, name, path, image);%0A%09%7D
 %0A%7D%0A

write constructor for game to take string from mcp