From 4c555281988424a83b004c06a3f85e60d1c9fc6e Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Thu, 26 Feb 2015 17:45:59 +0100 Subject: Finished week 4 --- Week4/src/oo15loipe/AsciiArt.java | 50 +++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 25 deletions(-) (limited to 'Week4/src/oo15loipe/AsciiArt.java') diff --git a/Week4/src/oo15loipe/AsciiArt.java b/Week4/src/oo15loipe/AsciiArt.java index 3ee3367..4072d54 100644 --- a/Week4/src/oo15loipe/AsciiArt.java +++ b/Week4/src/oo15loipe/AsciiArt.java @@ -1,18 +1,19 @@ -/* - * 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 + * 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); @@ -22,30 +23,29 @@ public class AsciiArt implements TekenLoipe{ 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++){ + 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('*'); - 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(' '); + } 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'); + System.out.print("\n"); } } } -- cgit v1.2.3