Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main;
- /**
- *
- * @author Jay
- */
- public class CashRegister {
- private int money; // Initialize the variable 'money' with the modifier of private
- // "The Constructor."
- public CashRegister() { // Whenever 'new CashRegister()' is called the logic inside here is called.
- money = 0; // Assign 'money' with the value of 0.
- }
- public int getMoney() { // Function returns the data type of an int.
- return money; //Return the variable money
- }
- public void setMoney(int newValue) { // Function that returns no data, requires one paramater that is an int
- money = newValue; // Assign 'money' to the value of newValue
- }
- public void increaseMoney(int gain) { // Function that returns no data, but requires one paramater that is an int
- money += gain; // money += gain means money = money + gain;
- }
- }
Add Comment
Please, Sign In to add comment