I am trying to call a variable from a different class so I can display and update the variable. I do not know how to properly call the variable and use it, eclipse throws up an error. Help would be much appreciated.
Thank you
What I have tried:
I have made the variable and gave it a value in a class called TicketHandler
public int TicketCost, AmountOfTickets;
public TicketHandler (int TicketCost, int AmountOfTickets){
this.TicketCost = TicketCost;
this.AmountOfTickets = AmountOfTickets;
}
public TicketHandler() {
TicketCost = 200;
AmountOfTickets = 50;
I have made the getter for the variable in the same class
public int getAmountOfTickets() {
return AmountOfTickets;
I have tried calling it in a different class by using this line
getAmountOfTickts = AmuontOfTickets - 1;
TicketHandler Red = new TicketHandler (200,50);
.
TicketHandler Green = new TicketHandler (200,50);
TicketHandler Blue = new TicketHandler (200,50);
TicketHandler Yellow = new TicketHandler (200,50);
These are some constructors that use the AmountOfTickets variable (the number 50)