diff --git a/app/src/main/java/hatelace/Main.java b/app/src/main/java/hatelace/Main.java index d380b1d..ac1aa2d 100644 --- a/app/src/main/java/hatelace/Main.java +++ b/app/src/main/java/hatelace/Main.java @@ -15,11 +15,7 @@ public class Main { computer.run(); memory.dump(); - // Print the program - System.out.println("Program:"); - for (Instruction instruction : program) { - System.out.println(instruction); - } + System.out.println(program); System.out.println("Completed"); } diff --git a/app/src/main/java/hatelace/Program.java b/app/src/main/java/hatelace/Program.java index 510478f..499ba62 100644 --- a/app/src/main/java/hatelace/Program.java +++ b/app/src/main/java/hatelace/Program.java @@ -3,4 +3,13 @@ package hatelace; import java.util.ArrayList; // This is simply an intermediate class to comply with the specified API requirements. -public abstract class Program extends ArrayList {} +public abstract class Program extends ArrayList { + public String toString() { + StringBuilder builder = new StringBuilder(); + for (Instruction instruction : this) { + builder.append(instruction.toString()); + builder.append("\n"); + } + return builder.toString(); + } +}