Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

made more general (lastEntry instead of lastEntryWasOrder)

  • Loading branch information...
commit b08b4d25d4be969a65e46affa6fc64652f1919e4 1 parent 60b626e
Ta'iř sj Ořit authored

Showing 1 changed file with 5 additions and 5 deletions. Show diff stats Hide diff stats

  1. +5 5 StringHolder.java
10 StringHolder.java
@@ -12,7 +12,7 @@
12 12 public ArrayList<String> orders;
13 13 public ArrayList<String> methods;
14 14 public ArrayList<String> imports;
15   - public boolean lastEntryWasOrder = false;
  15 + public String lastEntry = "none";
16 16 //Default Constructor
17 17 public StringHolder(){
18 18 orders = new ArrayList<String>();
@@ -27,15 +27,15 @@ void add(String entry){
27 27 entry.matches(" *import .*;");
28 28 if (entry.matches(" *import .*;")){
29 29 imports.add(entry);
30   - lastEntryWasOrder = false;
  30 + lastEntry = "import";
31 31 }
32 32 else if (entry.matches("}.*")){
33 33 methods.add(entry.substring(1));
34   - lastEntryWasOrder = false;
  34 + lastEntry = "method";
35 35 }
36 36 else
37 37 orders.add(entry);
38   - lastEntryWasOrder = true;
  38 + lastEntry = "order";
39 39 }
40 40 /**
41 41 * Returns the updated String that should be compiled
@@ -49,7 +49,7 @@ String toFile(){
49 49 base = base.concat("public static void main(String[] args){\n");
50 50 base = combine(orders.subList(0, (orders.size()-2)>0 ? orders.size()-2 : 0), base);
51 51 //still get error about void methods
52   - if (lastEntryWasOrder) base = base.concat("System.out.println( "+orders.get(orders.size()-1).substring(0,orders.get(orders.size()-1).length()-1)+");\n");
  52 + if (lastEntry.equals("order")) base = base.concat("System.out.println( "+orders.get(orders.size()-1).substring(0,orders.get(orders.size()-1).length()-1)+");\n");
53 53 base = base.concat("}\n}");
54 54 return base;
55 55 }

0 comments on commit b08b4d2

Please sign in to comment.
Something went wrong with that request. Please try again.