Java Tutorial Lesson 08: Matrices continued
From Erlands Wiki
You have this “Game” class:
public class Game { public static void main(String[] args) { System.out.println("Lesson 8"); System.out.println(); for (int i = 0; i < args.length; i++) { Room r = new Room(args[i]); char[][] roomData = r.getData(); for (int y = 0; y < roomData.length; y++) { char[] lines = roomData[y]; System.out.println(lines); } } } }
Your work is to create the “Room” class so when the “Game” class is called as:
java Game kalle ola nicklas
It should create an output as:
Lesson 8 ---------- | | | kalle | | | ---------- ---------- | | | ola | | | ---------- ---------- | | |nicklas | | | ----------
Some optionals things to try:
- Change the Game class so it prints the rooms horizonatlly instead of vertically
