From 6a44b074f0169a1b0f9e92347af929c5e471746e Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Sat, 18 Apr 2015 13:44:44 +0200 Subject: Reorganised projects --- Week4 Drawing loipes/src/oo15loipe/AsciiArt.java | 51 ++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 Week4 Drawing loipes/src/oo15loipe/AsciiArt.java (limited to 'Week4 Drawing loipes/src/oo15loipe/AsciiArt.java') diff --git a/Week4 Drawing loipes/src/oo15loipe/AsciiArt.java b/Week4 Drawing loipes/src/oo15loipe/AsciiArt.java new file mode 100644 index 0000000..4072d54 --- /dev/null +++ b/Week4 Drawing loipes/src/oo15loipe/AsciiArt.java @@ -0,0 +1,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"); + } + } +} -- cgit v1.2.3