Question
I am working on a java project I have 2 classes, Event and Play. Play extends Event. Event Class contains this variable -> protected static
I am working on a java project I have 2 classes, Event and Play. Play extends Event. Event Class contains this variable -> protected static final int CAPACITY = 5;
in Play class i tried to access CAPACITY and do the following calculations but getting a zero for some reason.
private int sixtyPercent = (Event.CAPACITY / 100) * 60;
private int eightyPercent = (Event.CAPACITY / 100) * 80;
i am using them for the following method but its going straight to else clause since both sixtyPercent and eightyPercent are 0
public boolean addTicket(Ticket ticket) {
if (ticketSize == sixtyPercent) {
this.setPriceFactor(1.2 * this.getPriceFactor());
ticketSize++;
this.getTickets().add(ticket);
return true; }
else if (ticketSize == eightyPercent) {
this.setPriceFactor(1.2 * this.getPriceFactor());
ticketSize++;
this.getTickets().add(ticket);
return true; }
else {
ticketSize++;
this.getTickets().add(ticket);
return true; } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started