Guest User

Untitled

a guest
Jul 22nd, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. package main;
  2.  
  3. /**
  4. *
  5. * @author Jay
  6. */
  7. public class CashRegister {
  8. private int money; // Initialize the variable 'money' with the modifier of private
  9.  
  10. // "The Constructor."
  11. public CashRegister() { // Whenever 'new CashRegister()' is called the logic inside here is called.
  12. money = 0; // Assign 'money' with the value of 0.
  13. }
  14.  
  15. public int getMoney() { // Function returns the data type of an int.
  16. return money; //Return the variable money
  17. }
  18.  
  19. public void setMoney(int newValue) { // Function that returns no data, requires one paramater that is an int
  20. money = newValue; // Assign 'money' to the value of newValue
  21. }
  22.  
  23. public void increaseMoney(int gain) { // Function that returns no data, but requires one paramater that is an int
  24. money += gain; // money += gain means money = money + gain;
  25. }
  26. }
Add Comment
Please, Sign In to add comment