1. John Louis del Rosario
  2. expenses

Commits

John Louis del Rosario  committed 25fe1a2

Continue on graph.

  • Participants
  • Parent commits aedd0b6
  • Branches default

Comments (0)

Files changed (3)

File ExpenseParser.pde

View file
  • Ignore whitespace
 import java.text.SimpleDateFormat;
 import java.util.Date;
 
-class Expense{
-  private Date date;
-  private String type;
-  private String amount;
-  private String currency;
-  private String paidWith;
-  private String category;
-  private String note;
-  private String list;
-
-  // constructor
-  public Expense(String date, String type, String amount, String currency, String paidWith, String category, String note, String list){
-    DateFormat df = new SimpleDateFormat("MM/dd/yyyy");
-    try{
-      this.date = df.parse(date);
-    }catch(ParseException e){
-      println(e.getMessage());
-      println("!!" + date);
-    }
-    this.type = type;
-    this.amount = amount;
-    this.currency = currency;
-    this.paidWith = paidWith;
-    this.category = category;
-    this.note = note;
-    this.list = list;
-  }
-
-  public Date getDate(){
-    return this.date;
-  }
-  public String getType(){
-    return this.type;
-  }
-  public float getAmount(){
-    return float(this.amount);
-  }
-  public String getCurrency(){
-    return this.currency;
-  }
-  public String getPaidWith(){
-    return this.paidWith;
-  }
-  public String getCategory(){
-    return this.category;
-  }
-  public String getList(){
-    return this.list;
-  }
-  public String toString(){
-    String str = "";
-    str += getDate().toString() + ";";
-    str += getType() + ";";
-    str += Float.toString(getAmount()) + ";";
-    str += getCurrency() + ";";
-    str += getPaidWith() + ";";
-    str += getCategory() + ";";
-    str += getList() + ";";
-    return str;
-  }
-
-}
 
 class ExpenseParser{
   private Expense[] expenses;

File ExpenseRenderer.pde

View file
  • Ignore whitespace
 class ExpenseRenderer {
+  private ExpenseParser ep;
   public ExpenseRenderer(int w, int h){
     size(w, h);
     background(65);
   }
 
   private void init(){
+    ep = new ExpenseParser("Expenses.csv");
     drawGraph();
+    plotPoints();
+  }
+
+  /*
+   * Get and set info for graph drawing
+   */
+  private void getGraphInfo(){
+
   }
 
   /*
   private void drawGraph(){
     stroke(255);
     line(20, 20, 20, height - 20);
+    line(20, height - 20, width - 20, height - 20);
+  }
+
+  /*
+   * Plot the expenses on the graph
+   */
+  private void plotPoints(){
+    fill(255);
+    Expense[] expenses = ep.getAllExpenses();
+    println(expenses.length);
+    for (int i = 0; i < expenses.length; i++){
+      float x = expenses[i].getDate();
+      float y = expenses[i].getAmount();
+    }
   }
 }

File expenses.pde

View file
  • Ignore whitespace
 void setup(){
   ExpenseRenderer er = new ExpenseRenderer(400, 400);
-  ExpenseParser ep = new ExpenseParser("Expenses.csv");
   //ep.getExpensesForDate("1/1/2011");
   //ep.getExpensesForDateRange("1/1/2011", "3/31/2011");
 }