document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. public class TicketMachine extends IntMain
  2. {
  3.     // instance variables - replace the example below with your own
  4.     private int price;
  5.     private int balance;
  6.     private int total;
  7.  
  8.     /**
  9.      * Constructor for objects of class price
  10.      */
  11.     public TicketMachine(int ticketCost)//constructor
  12.     {
  13.         // initialise instance variables
  14.         price = ticketCost;
  15.         balance = 0;
  16.         total = 0;
  17.     }
  18.  
  19.     /**
  20.      * An example of a method - replace this comment with your own
  21.      *
  22.      * @param  y  a sample parameter for a method
  23.      * @return    the sum of x and y
  24.      */
  25.     public int getPrice()//accessor
  26.     {
  27.         // put your code here
  28.         return price;
  29.     }
  30.     public int getBalance(){//accessor
  31.         return balance;
  32.     }
  33.     public void insertMoney(int amount){//mutator
  34.         balance = balance+amount;
  35.     }
  36.     public void printTicket(){
  37.         System.out.println("############");
  38.         System.out.println("# The BlueJ Line");
  39.         System.out.println("# " + price + " cents.");
  40.         System.out.println("############");
  41.         System.out.println();
  42.         total=total+balance;
  43.         balance=0;
  44.     }
');