You are to create a ticketing machine for a cinema, more specifically just 1 movie.
To start, create an object contructor for a specific movie called var Movie
.
The object constructor should have these properties (how do we pass these information to the contructor?):
- title (string)
- timeOfPlay (number ex: 1600)
- seats (array of an array)
- maxCapacity (number)
- price (object) a. adult (number) b. child (number)
- ticketSold (object) a. adult (number) b. child (number)
- getRevenue (function)
- Ticket (object contructor for ticket)
- generateTicket (function)
- The following is an example of the seating plans
seats
. It is an array of an array.'x' = taken
and'o' = empty
.
movie = {
seats: [
['o','o','o','o','o'],
['o','o','o','o','o'],
['o','o','o','o','o'],
['o','o','o','o','o']
]
}
- The
price
&ticketSold
is an object with two key value pair.
movie = {
price: {
adult: 100,
child: 80
},
ticketSold: {
adult: 0,
child: 0
}
}
-
getRevenue
is a function that takes the product ofprice
andticketSold
and return the total revenue. -
Ticket
is an object constructor for a new ticket. This contructor has the following properties: -
seat (coordinate in form of an array of number)
-
seatType ('adult' or 'child')
-
price (number)
-
timeOfPlay (number ex: 1600)
-
generateTicket
is a function that takes in what the customer wants. EX: I am a adult, i want a seat on [0, 2] that is the middle seat at the top row. What this function should do is take this input, check the seats to make sure the seat is not already taken, take record of ticket being sold, and generate & return the ticket.
There is no starter code for this. Just fork and clone this repo.