Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Mastering Real Time Analytics In Big Data A Comprehensive Guide For Everyone

Authors: Lennox Mark

1st Edition

B0CPTC9LY9, 979-8869045706

More Books

Students also viewed these Databases questions