1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
GenaCL600 [577]
4 years ago
7

Write the constructor for the Theater class. The constructor takes three int parameters, representing the number of seats per ro

w, the number of tier 1 rows, and the number of tier 2 rows, respectively. The constructor initializes the theater Seats instance variable so that it has the given number of seats per row and the given number of tier 1 and tier 2 rows and all seats are available and have the appropriate tier designation.
Computers and Technology
1 answer:
sp2606 [1]4 years ago
5 0

Answer:

See explaination

Explanation:

class Seat {

private boolean available;

private int tier;

public Seat(boolean isAvail, int tierNum)

{ available = isAvail;

tier = tierNum; }

public boolean isAvailable() { return available; }

public int getTier() { return tier; }

public void setAvailability(boolean isAvail) { available = isAvail; } }

//The Theater class represents a theater of seats. The number of seats per row and the number of tier 1 and tier 2 rows are

//determined by the parameters of the Theater constructor.

//Row 0 of the theaterSeats array represents the row closest to the stage.

public class Theater {

private Seat[][] theaterSeats; /** Constructs a Theater object, as described in part (a). * Precondition: seatsPerRow > 0; tier1Rows > 0; tier2Rows >= 0 */

public Theater(int seatsPerRow, int tier1Rows, int tier2Rows) {

theaterSeats= new Seat[tier1Rows+tier2Rows][seatsPerRow];

}

public boolean reassignSeat(int fromRow, int fromCol, int toRow, int toCol) {

if(theaterSeats[toRow][toCol].isAvailable()) {

int tierDestination =theaterSeats[toRow][toCol].getTier();

int tierSource =theaterSeats[fromRow][fromCol].getTier();

if(tierDestination<=tierSource) {

if(tierDestination==tierSource) {

if(fromRow<toRow) {

return false;

}else {

theaterSeats[toRow][toCol].setAvailability(false);

theaterSeats[fromRow][fromCol].setAvailability(true);

return true;

}

}

theaterSeats[toRow][toCol].setAvailability(false);

theaterSeats[fromRow][fromCol].setAvailability(true);

return true;

}else {

return false;

}

}else {

return false;

}

}

public static void main(String[] args) {

//Lets understand it with simple example

Theater t1 = new Theater(3,1,2);

//Our threater has 3 seat in each row and we have one tier 1 row and 1 tier 2 row

//total no of seat will be 9.

//Lets create our seat

t1.theaterSeats[0][0] = new Seat(true,1);

t1.theaterSeats[0][1] = new Seat(false,1);

t1.theaterSeats[0][2] = new Seat(true,1);

t1.theaterSeats[1][0] = new Seat(true,2);

t1.theaterSeats[1][1] = new Seat(true,2);

t1.theaterSeats[1][2] = new Seat(true,2);

t1.theaterSeats[2][0] = new Seat(false,2);

t1.theaterSeats[2][1] = new Seat(false,2);

t1.theaterSeats[2][2] = new Seat(true,2);

//Lets print out theater and see which seat is available or which is not

System.out.println("Theater===>");

for(int i=0;i<3;i++) {

for(int j=0;j<3;j++) {

System.out.print("["+i+"]"+"["+j+"] : "+t1.theaterSeats[i][j].isAvailable()+" ");

}

System.out.println();

}

System.out.println("(2,1) want to change seat to (0,0)");

System.out.println("["+2+"]"+"["+1+"]"+"===>"+"["+0+"]"+"["+0+"]");

t1.reassignSeat(2, 1, 0, 0);

for(int i=0;i<3;i++) {

for(int j=0;j<3;j++) {

System.out.print("["+i+"]"+"["+j+"] : "+t1.theaterSeats[i][j].isAvailable()+" ");

}

System.out.println();

}

}

}

You might be interested in
Need 9&amp;10. Thank you! Btw it's due today.
NeTakaya
Q9. The metric system is an internationally adopted decimal system of measurement. It is widely used in the world and is the only or most common system of weights and measures. It is now known as the International System of Units (SI). It is used to measure everyday things such as a sack of flour, the height of a person, a tank of petrol, and the speed of a car. On the other hand, the United States customary units are a system of measurements commonly used in the United States. So, for the measurement above we have:

Distance from Los Angeles:

Given that the problem does not tell us the specific point for the distance from Los Angeles. We will assume that this point is New York, so:

*Metric: The unit for length is the meter.

d = 4488460 (m)

*U.S customary: For measuring length, the U.S. customary system uses the inch, foot, yard, and mile, so:

d = 176711023 (in)
d = 14725918 (ft)
d = 4908639 (yd)
d = 2789 (mi)

The temperature on a hot day:

*Metric: Degree Celsius is a unit of thermodynamic temperature. So, on a hot day the temperature is:

T = 35°

*U.S customary: Degrees Fahrenheit is used in the U.S. to measure temperatures, so:

T = 95°

The weight of a loaf of bread: 

*Metric: The unit used for mass is the kilogram. For a mass of 0.095 (kg), the weight that is a force (Newton is the unit for measuring weight) is given by:

w = 0.931 (N)

*U.S customary: Ounces is a unit of weight for this system, so:

w = 1 ounce

Length of a pencil: 

*Metric:
d = 0.095(m)

*U.S customary: 

d = 3.74 (in)
d = 0.311(ft)
d = 0.10 (yd)
d = 5.90 (mi)

The capacity of a container:

The capacity of an element is equal to the volume that is the quantity of three-dimensional space enclosed by a closed surface, so the capacity of a container very used these days  is:

*Metric: 

V = 33.2m^{3}

*U.S customary: The cubic inch, cubic foot and cubic yard are commonly used for measuring volume. So:

V=2025988in^{3}
V =1172.44ft^{3}
V =43.42yd^{3}

<span>Q10. We can explain this concept using an example for Small Businesses. The concept of Frustrated Users (Employees) is an example of a technological problem. Interacting with technology is a huge part of the employees’ day. Using slow, outdated systems with frequent problems makes it much more difficult for them to be happy and productive. How would it impact a business if the company enabled the employees to get just 5 percent more accomplished every day? the answer is simply by keeping the technology up to date. So, the problem exposed above allows the company to find new ways and opportunities to make the job easier. The company would need to establish a training plan for the employees. Maybe establishing a diploma course that allows them to learn and know better the new technologies.</span>
4 0
3 years ago
Several people work with data at Erica’s office. She enters data. One of her coworkers enters new product numbers. Another cowor
Dvinal [7]

Answer:

a software program for storing, managing, and retrieving information

Explanation:

8 0
3 years ago
When should an individual consider entering parenthood?
-BARSIC- [3]
  In my opinion, after marriage. And during the time you're married, be sure you are going to stay with that person a long time because divorces can cause mental health issues towards the child. And if your loved one is abusive, an alcoholic, etc. then you should get out that relationship immediately before having children. Therefore, your children will have a happy, healthy, life. 
5 0
3 years ago
​_____ refers to​ internet-based platforms that allow users to create their own content and share it with others who access thes
liberstina [14]
This would be considered a social media platform due to it allowing people to share content.<span />
6 0
3 years ago
Which expansion slot is best for high-end dedicated video cards?
Contact [7]

Solution:

It is done Motherboard.

The motherboard includes most of the slots that we'll run into these days. It's a little unusual in that we don't often see motherboards which have both PCI-Express slots and an AGP slot. The best slot to use for video cards is the PCI-Express x16 slot. The next best is the AGP slot. The next best is a PCI-Express x1 slot but video cards which fit that slot are very hard to find as of late 2006. Some low-budget computers are sold with integrated video and have neither PCI-Express x16 slot or an AGP slot.

3 0
3 years ago
Other questions:
  • Which of the following is not a standard method called as partof the JSP life cycle?
    5·1 answer
  • An effective password can help prevent
    11·2 answers
  • Which option will you use to expose your presentation to the audience?
    8·2 answers
  • EMERGENCYYYYY what does it mean when i get a security alert when i download an addon on google docs
    7·1 answer
  • Pen registers and trap-and-trace devices are not considered forms of searches and do not need probable cause and a court order b
    10·1 answer
  • One side in a Transmission Control Protocol (TCP) connection has not been able to properly recover from a series of malformed se
    6·1 answer
  • Kareem is working on a project for his manager. He has a few questions for a co-worker who he knows is knowledgeable on the subj
    7·1 answer
  • Software that is decided to intentionally causing harm to a device, server, or network is 
    13·2 answers
  • 1. Tracy is studying to become an esthetician. Give three reasons why she needs to have a thorough
    11·1 answer
  • Question 1 of 10
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!