Program implements toString
This commit is contained in:
parent
b97d09ac5b
commit
4b11ef49e7
2 changed files with 11 additions and 6 deletions
|
@ -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");
|
||||
}
|
||||
|
|
|
@ -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<Instruction> {}
|
||||
public abstract class Program extends ArrayList<Instruction> {
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for (Instruction instruction : this) {
|
||||
builder.append(instruction.toString());
|
||||
builder.append("\n");
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue