/* * 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'); } } }