diff options
Diffstat (limited to 'Week4 Drawing loipes/src/oo15loipe/AsciiArt.java')
-rw-r--r-- | Week4 Drawing loipes/src/oo15loipe/AsciiArt.java | 51 |
1 files changed, 51 insertions, 0 deletions
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");
+ }
+ }
+}
|