My problem is this: I have a class, let it be called the Theatre .
This Theatre has a constructor in which I indicate the amount of Seats that this Theatre .
The Show class has a set of Seats , each with its own properties, such as bool Empty .
So, we summarize the code:
class Theatre { public Theatre(int numberOfSeats) { this.numberOfSeats = numberOfSeats; } }
Suppose we create 100 somewhere.
Theatre myTheatre = new Theatre(100);
For class Show :
class Show { List<Seats> listOfSeats = new List<Seats>(); public Show() { for (int i = 0; i < 100; i++)
I'm new to oop , so bare with me.
My problem is that I do not know how to get rid of this 100 .
I would like to have something like myTheatre.NumberOfSeats, but I'm not quite sure how this will work.
My problem is that I already created myTheatre in a different class, so I would have to create a new theater inside the Show , just to get the number of seats, I would use something like composition and deletion, but this is clearly violated by the ISP.
But even this has a problem, because when I create a new Theatre , I would have to put 100 as a parameter and, if it was necessary to change, I would have to manually change it.
So my questions are:
- Am I missing something obvious? (Very likely)
- Which approach would you recommend?
- Is there something like a shared variable in classes? (I do not want to use the word global, because I'm not sure what I want, but maybe).
As an obvious clarification, the above is not an actual code, but just a presentation to clarify the situation.