Android Open Source - As1-301-CounterApp Counter






From Project

Back to project page As1-301-CounterApp.

License

The source code is released under:

GNU General Public License

If you think the Android project As1-301-CounterApp listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package pack.as1_301;
/*from w ww. ja  v a 2 s.  co m*/
import java.util.ArrayList;
import java.util.Date;

public class Counter {
  private String name;
  private int count;
  private ArrayList<Date> changes;

  // Constructor: takes a string that will be stored as the name of the counter
  public Counter(String counterName) {
    name = counterName;
    count = 0;
    changes = new ArrayList<Date>();
  }
  
  public String getName() {
    return name;
  }
  
  public void setName(String name) {
    this.name = name;
  }
  
  public int getCount() {
    return count;
  }
  
  // increments the counter's value and logs the increment
  public void incCount() {
    count++;
    Date date = new Date();
    changes.add(date);
  }
  
  // resets the counter's value and resets it's log
  public void resetCount() {
    count = 0;
    changes.clear();
  }
  
  public ArrayList<Date> getChanges() {
    return changes;
  }

  // returns the counter's name when called
  public String toString() {
    return name;
  }

}




Java Source Code List

pack.as1_301.CounterActivity.java
pack.as1_301.CounterSettingsActivity.java
pack.as1_301.CounterStatsActivity.java
pack.as1_301.Counter.java
pack.as1_301.CreateCounterActivity.java
pack.as1_301.MainActivity.java