aboutsummaryrefslogtreecommitdiff
path: root/Week4/src/oo15loipe/AsciiArt.java
diff options
context:
space:
mode:
Diffstat (limited to 'Week4/src/oo15loipe/AsciiArt.java')
-rw-r--r--Week4/src/oo15loipe/AsciiArt.java50
1 files changed, 25 insertions, 25 deletions
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");
}
}
}