blob: 4072d5427b3d403dd57dc1e0fa3de0a5b5de8e58 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
package oo15loipe;
/**
* A class that draws the loipe as ascii-art.
*
* @author Thijs Heijligenberg, s4451414, Camil Staps, s4498062
*/
public class AsciiArt implements TekenLoipe{
private InfoLoipe L;
private Punt man;
/**
* Create the instance based on a loipe
*
* @param s
*/
public AsciiArt(InfoLoipe s){
this.L = s;
this.man = new Punt(null);
}
@Override
public void setPosition(Punt p){
this.man = p;
}
@Override
public void teken(){
for(int j = 0; j < L.getHeight(); j++){
for(int i = 0; i < L.getWidth(); i++){
Fragment f = L.getFragment(i,j);
if(i == man.getX() && j == man.getY()){
System.out.print('*');
} else if (f == null) {
System.out.print(' ');
} else {
switch (f){
case KR: System.out.print('+'); break;
case NZ: System.out.print('|'); break;
case OW: System.out.print('-'); break;
case NO: System.out.print('`'); break;
case NW: System.out.print(','); break;
case ZO: System.out.print(','); break;
case ZW: System.out.print('.'); break;
}
}
}
System.out.print("\n");
}
}
}
|