There are two obvious things you could do as far as how you're thinking about the section of the Seats.
Scenario 1:
Think of the section the seat is in as a property of the seat. (In other words, since the seat will always be in the same section, you could have a variable in the Seat class called section).
Scenario 2:
Think of the section the seat is in as a property of the Theater- not of the seat. In this case, your Theater class could have an array of seats for each section. This is what I would personally do, I think.
BestJewSinceJC
Posting Maven
2,772 posts since Sep 2008
Reputation Points: 874
Solved Threads: 354
Lets say you have three sections. Then you would have three arrays of seats, one for each section.
public class Theater{
-seat array here
-second seat array here
-third seat array here
}
BestJewSinceJC
Posting Maven
2,772 posts since Sep 2008
Reputation Points: 874
Solved Threads: 354
A more generalized Theater class design would have either a single collection of seats with the section, price, etc being properties of the seats, or another intermediate collection class to represent seating sections that contained their own collections of seats.
Theaters do not all share common layouts or number of seats, so hard-coding in three arrays for seats ties your implementation to a theater that had three distinct sections of seats with different properties.
Ezzaral
Posting Genius
15,986 posts since May 2007
Reputation Points: 3,250
Solved Threads: 847
I understand reusability and coupling (not sure if the OP does or doesn't) but if I was writing this, I'd probably feel that your suggestion is needlessly complex and doesn't offer enough benefit to justify the extra work. Maybe I'm wrong - I'd like to see a seating collection that actually offers some benefit
BestJewSinceJC
Posting Maven
2,772 posts since Sep 2008
Reputation Points: 874
Solved Threads: 354
Putting in a SeatingSection class probably is more complex than the OP needs for this assignment. I just threw that in as a consideration to get them thinking a bit. I think all they really need is a single collection, List or array, of Seats.
Ezzaral
Posting Genius
15,986 posts since May 2007
Reputation Points: 3,250
Solved Threads: 847