blob: 3ee3367e241354c661a6560996f81d4fb064ecd4 (
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
|
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package oo15loipe;
/**
* a class that draws the loipe as ascii-art.
* @author theijligenberg
*/
public class AsciiArt implements TekenLoipe{
private InfoLoipe L;
private Punt man;
public AsciiArt(InfoLoipe s){
this.L = s;
this.man = new Punt(null);
}
@Override
public void setPosition(Punt p){
this.man = p;
}
/**
* draws the loipe by checking each fragment at (i,j) for its direction
*/
@Override
public void teken(){
for(int i = 0; i < L.getWidth(); i++){
for(int j = 0; j < L.getHeight(); j++){
if(i == man.getX() && j == man.getY()){
System.out.print('*');
break;
}
Fragment f = L.getFragment(i,j);
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;
default: System.out.print(' ');
}
}
System.out.print('\n');
}
}
}
|