First, head here to join our Zoom meeting. It will help me following along while you work through the assignment.
Write a program that calculates purchase price for movie tickets using any language you like. It should not be a full-blown web app; it can be a simple class or collection of methods invokable by your test suite. We'll provide you with some requirements, test-cases, and even a sample interface - all you have to do is give us some software.
The Base Admission Rate cover movies to be viewed on a regular weekday (see "Special Movie Day" below), in 2D, with a length of <= 120 minutes, viewed from the main seating area (there is also a balcony seating area, which is much fancier).
- General Admission, $11.00/ticket
- Students (where 13 <= age < 64 years of age), $8.00/ticket
- Senior Citizen (65 & older), $6.00/ticket
- Children (under 13), $5.50/ticket
- Group Pricing (if 20 people or more), max of $6.00/ticket (i.e. tickets for 30 children, 2D, Monday showing, 90 minutes, main seating area would cost
30 * 5.50
instead of30 * 6.00
)
There are some exceptional cases which can cause us to add/subtract from a ticket's price:
- If watching a 3D movie, add $3.00/ticket
- If the movie's duration is greater than 120 minutes, add $1.50/ticket
- On Special Movie Day (Thursday, but does not apply if group-pricing), subtract $2.00/ticket
- On Weekends (Saturday and Sunday), add $1.50/ticket
- If seated in the balcony area, add $2.00/ticket
4 tickets for 35 year-olds (General Admission), 3D, 90 minute duration, Thursday, balcony seating == $56.00
base price
* general admission: 4 x $11.00 == $44.00
modifications
* 3D movie: 4 x 3.00 == 12.00
* balcony: 4 x 2.00 == 8.00
* Special Movie Day: 4 x -2.00 == -8.00
------
$56.00
- Movie tickets must be purchased and consumed on the same day
- All of the movie tickets for a single purchase must be for the same showing
- All of the moviegoers for a single purchase will be seated in the same area
- quantitative: 1 point per test case completed (max 16)
- qualitative: consistent, clean, idionmatic code
In Ruby, we might write something like:
class MovieTicketPurchase
def initialize(movie_duration_minutes, day_of_week, is_balcony_seats, is_3d)
end
def add_ticket(viewer_age, viewer_is_student)
end
def finish
end
end
...and use it like so:
p = MovieTicketPurchase.new(90, :tuesday, false, false)
p.add_ticket(35, false)
p.add_ticket(35, false)
p.add_ticket(35, false)
p.add_ticket(35, false)
p.finish() # 44.00
- 0 tickets == $0.00
- 4 x 35 year-olds, 2D, 90 minute duration, Tuesday, normal seating == $44.00
- 4 x 35 year-olds, 3D, 90 minute duration, Tuesday, normal seating == $56.00
- 21 x 35 year-old, 2D, 90 minute duration, Tuesday, normal seating == $126.00
- 4 x 35 year-olds, 3D, 90 minute duration, Tuesday, balcony seating == $64.00
- 4 x 35 year-olds, 3D, 90 minute duration, Thursday, balcony seating == $56.00
- 4 x 35 year-olds, 2D, 240 minute duration, Monday, normal seating == $50.00
- 4 x 35 year-olds, 3D, 90 minute duration, Saturday, balcony seating == $70.00
- 4 x 9 year-olds, 2D, 90 minute duration, Monday, normal seating == $22.00
- 4 x 67 year-olds, 2D, 90 minute duration, Monday, normal seating == $24.00
- 4 x 14 year-old students, 2D, 90 minute duration, Monday, normal seating == $32.00
- 1 x each type (student, regular, senior, child), 2D, 90 minute duration, Monday, normal seating == $30.50
- 21 x 9 year-olds, 2D, 90 minute duration, Monday, normal seating == $115.50
- 21 x 35 year-old, 2D, 90 minute duration, Thursday, normal seating == $126.00
- 10 x 14 year-old students + 11 x 9 year-olds, 2D, 90 minute duration, Monday, normal seating == $120.50
- 7 x each type (student, regular, senior, child), 3D, 240 minute duration, Thursday, balcony seating == $346.50
- Get as far as you can in 60 minutes
- Feel free to ask questions
- You can use the internet to look up programming-related things