Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

made more general (lastEntry instead of lastEntryWasOrder)

  • Loading branch information...
commit b08b4d25d4be969a65e46affa6fc64652f1919e4 1 parent 60b626e
Ta'iř sj Ořit authored
Showing with 5 additions and 5 deletions.
  1. +5 −5 StringHolder.java
10 StringHolder.java
View
@@ -12,7 +12,7 @@
public ArrayList<String> orders;
public ArrayList<String> methods;
public ArrayList<String> imports;
- public boolean lastEntryWasOrder = false;
+ public String lastEntry = "none";
//Default Constructor
public StringHolder(){
orders = new ArrayList<String>();
@@ -27,15 +27,15 @@ void add(String entry){
entry.matches(" *import .*;");
if (entry.matches(" *import .*;")){
imports.add(entry);
- lastEntryWasOrder = false;
+ lastEntry = "import";
}
else if (entry.matches("}.*")){
methods.add(entry.substring(1));
- lastEntryWasOrder = false;
+ lastEntry = "method";
}
else
orders.add(entry);
- lastEntryWasOrder = true;
+ lastEntry = "order";
}
/**
* Returns the updated String that should be compiled
@@ -49,7 +49,7 @@ String toFile(){
base = base.concat("public static void main(String[] args){\n");
base = combine(orders.subList(0, (orders.size()-2)>0 ? orders.size()-2 : 0), base);
//still get error about void methods
- if (lastEntryWasOrder) base = base.concat("System.out.println( "+orders.get(orders.size()-1).substring(0,orders.get(orders.size()-1).length()-1)+");\n");
+ 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");
base = base.concat("}\n}");
return base;
}
Please sign in to comment.
Something went wrong with that request. Please try again.