fork(1) download
  1. class Ideone{
  2.  
  3. public static void main(String []args){
  4.  
  5. CashRegister register1 = new CashRegister();
  6.  
  7. register1.addItem(1.95);
  8.  
  9. System.out.println(register1.getCount());
  10. }
  11.  
  12. }
  13.  
  14.  
  15. class CashRegister{
  16. private int itemCount;
  17. private double totalPrice;
  18.  
  19.  
  20. CashRegister(){
  21. itemCount=0;
  22. totalPrice=0;
  23. }
  24.  
  25. public void addItem(double price){
  26.  
  27. itemCount++;
  28. totalPrice=totalPrice + price;
  29. }
  30.  
  31. public double getTotal(){
  32. return totalPrice;
  33. }
  34.  
  35. public int getCount(){
  36. return itemCount;
  37. }
  38. public void clear(){
  39. itemCount=0;
  40. totalPrice=0;
  41. }
  42. }
Success #stdin #stdout 0.1s 320512KB
stdin
Standard input is empty
stdout
1