You are on page 1of 8

INFO6121 Assignment #3

“If your code fails to compile you will be assigned a mark of 0”


Instructions
In this assignment you will be designing classes according to the provided UML diagram and instructions.
You are creating a program that will create movie membership accounts that will allow members to
purchase movie tickets, earn points, and access VIP privileges. All properties and behaviours should
match the document specifications below.

Details
MovieMembership The top class in the hierarchy is the abstract
- memberName: String class MovieMembership. MovieMembership
- nextMovie: String properties include a name, movie points, and details
- theatreType: String about the next movie they will be watching:
- showHour: int - nextMovie: the movie’s title
- showMinutes: int - theatreType: is the movie standard or in IMAX
- snack: String - showHour & showMinutes: the time the movie
- points: int
is playing
+ MovieMembership (memberName: String)
- snack: The treat they will have to eat
+ MovieMembership (memberName: String,
nextMovie: String, theatreType: String, There are 2 constructor methods. The first will
showHour: int, showMinute: int, snack: String) accept the member’s name and will set the
remaining properties to:
+ getMemberName() : String
- nextMovie = “unknown”
+ getNextMovie(): String
- theatreType = “standard”
+ getPoints(): int
+ getSnacks(): String - showHour = 0
+ getTheatreType(): String - showMinutes = 0
+ setNextMovie(nextMovie: String): void - snack = “unknown”
+ setSnack(snack: String): void - points = 0
+ setTheatreType(theatreType: String): void The second constructor method will set all the
+ setShowtime(hour: int, minute: int): void parameters to their appropriate properties and set
points to 0.
+ displayShowTime(): String displayShowTime() will return a string of showHour
+ addPoints(points: int): void concatenated to a “:” followed by the showMinutes.
+ getMemberDetails(): String The addPoints() method will add the value of the
+ returnMembershipRank(): String points parameter to the points property.
+ printMemberBenefits(): void
getMemberDetails() will return a string that includes
+ purchaseMovieTicket(ticketPrice: double,
all of the properties of MovieMembership.
nextMovie: String, theatreType: String,
showHour: int, showMinute: int, snack: returnMembershipRank(), printMemberBenefits(),
String): void and purchaseMovieTicket() are all abstract methods
that will be overridden by the subclasses (see below).
SilverMember The SilverMember class is a subclass of
MovieMembership and represents members with
- discountRate: double
a rank of Silver. They will be entitled to discounts
- pointsRate: double
on ticket purchases and will earn points when
+ SilverMember (memberName: String)
making said purchases. All silver members start
+ SilverMember (memberName: String,
discountRate: double, pointsRate: double) with 0 points. There are 4 different constructor
+ SilverMember (memberName: String, methods. The first and third constructor methods
nextMovie: String, theatreType: String, should set the discountRate to 0.1 and pointsRate
showHour: int, showMinute: int, snack: String) to 1.2.
+ SilverMember (memberName: String, The first and second constructor methods should
nextMovie: String, theatreType: String, invoke the 1-argument constructor method of the
showHour: int, showMinute: int, snack: String, MovieMembership class (using the super
discountRate: double, pointsRate: double) keyword) while the third and fourth constructor
methods should invoke the 6-argument
+ getMemberDetails(): String constructor method of the MovieMembership
+ printMemberBenefits (): void
class.
+ returnMembershipRank(): String
+ purchaseMovieTicket(ticketPrice: double, The returnMembershipRank() method should
nextMovie: String, theatreType: String, return the string “Silver”. getMemberDetails()
showHour: int, showMinute: int, snack: String):should invoke the parent version to retrieve the
void string and concatenated it to the string returned
from the returnMembershipRank() method. printMemberBenefits() should output the discount rate and
point rate to the screen.

The purchaseMovieTicket() method should set the nextMovie, showHour, showMinute, and
theatreType, snacks properties using the appropriate setter methods and calculate the following
formula:
priceWithDiscount = ticketPrice * (1 – discountRate)
pointsEarned = (int)(ticketPrice * pointRate);
//points earned should then be added to the points property using addPoints()

purchaseMovieTicket() should then print the following:

“The Movie <nextMovie> has been purchased by <memberName> for <priceWithDiscount> and will be
showing at <show time> with <theatreType> screening. They have earned <pointsToAdd> points”

<<interface>> VIPPrivilege is an interface that will be


VIPPrivilege implemented by GoldMember (described below).
+ PASSWORD: int VIPPrivilege has a constant variable called
+ accessVIPLounge(): void PASSWORD that is a 4 digit long number.
+ purchaseAlcohol(): String VIPPrivilege also contains two abstract methods
that will be overridden in the GoldMember class. They are accessVIPLounge() and purchaseAlcohol().
GoldMember GoldMember is a subclass of the
- validCredentials: boolean SilverMember class and implements the
+ GoldMember(memberName: String) VIPPrivilege interface. All gold member accounts
+ GoldMember(memberName: String, have a discount rate of 0.25 and a points rate of
nextMovie: String, theatreType: String, 2.0 and begin with 50 points. GoldMember has
showHour: int, showMinute: int, snack: String) two constructor methods. The first should invoke
the 3-argument constructor method of
+ returnMembershipRank(): String
SilverMember and the second constructor
+ getMemberDetails(): String
method should invoke the 8-argument
+ accessVIPLounge(): void
+ purchaseAlcohol(): String constructor of SilverMember. Both constructor
methods should assign validCredentials to false.

The returnMembershipRank() method should return the string “Gold”. Override the
getMemberDetails() method for this class so that it will return the details of the parent class along with
a concatenated string that will mention the member is entitled to VIP privileges.
The accessVIPLounge() method should create a scanner object and prompt the user to enter a
password. Scan in the password and compare it to the PASSWORD constant from the VIPPrivilege
interface. If the password is correct, set validCredentials to true and output “Access granted!”.
The purchaseAlcohol() method should check the value of validCredentials. If true, invoke the setSnack()
method and set the value to “alcohol” and return the string “Enjoy your beverage”. Otherwise return a
string telling the user that a beverage cannot be purchased because no valid password has been
entered.

IMAXMember IMAXMember is a subclass of


- discountRate: double MovieMembership. All IMAX member accounts
- pointsRate: double start with 25 points and have a discount rate of
+ IMAXMember (memberName: String) 0.5 and points rate of 1.3. However, the discount
+ IMAXMember (memberName: String, rate and points rate only apply if the theatre type
nextMovie: String, theatreType: String, is set to “IMAX”. IMAXMember has two
showHour: int, showMinute: int, snack: String) constructor methods, the first should invoke the
1-argument constructor method of
+ getMemberDetails(): String
MovieMembership and the second should invoke
+ printMemberBenefits (): void
+ returnMembershipRank(): String the 6-argument constructor method of
+ purchaseMovieTicket(ticketPrice: double, MovieMembership.
nextMovie: String, theatreType: String,
showHour: int, showMinute: int, snack: String): printMemberBenefits()should print the discount
void rate and points rate. returnMembershipRank()
method should return a string with the value
“IMAX”. Override the getMemberDetails() method for this class so that it will return the member details
of the parent class along with a concatenated string that will call the returnMembershipRank() method.
The purchaseMovieTicket() method should function the same as the SilverMember’s version EXCEPT the
discount rate and purchase rate should only be applied if the theatre type has a value of “IMAX”.
Testing Your Class Hierarchy
Once you have your classes and interface created, make a java file called MovieMembershipTest.java
which will do the following:

1. Create three movie membership objects, one of each type (SilverMember, GoldMember,
IMAXMember). Make the data type of each variable the same class as the object they will hold.

The first member is a Silver Member. Create the object with whatever name, movie, theatre type, show
hour, show minute, and snacks you want. Name this object mySilver.

The second member is a Gold Member. Again, create the object with whatever name, movie, theatre
type, show hour, show minute, and snacks you want. Name this object myGold.

The third member is an IMAX Member. The name, movie, show times, and snack can be whatever you
want but the theatre type should be “IMAX”. Name this object myIMAX.

2. Create an array of type MovieMembership named movieMembershipArray with a size of 3 elements.


Assign each customer object you created in Step 1 to an element of your customer array. Just use a
straight assignment statement to do this as you create the object. Do not bother setting up a loop to
enter the objects into the array.

3. Create a for loop that will traverse through every element of the movieMembershipArray. For each
element of the array, output all of the following methods:
- getMemberName()
- returnMembershipRank()
- getNextMovie()
- getPoints()
- getSnacks()
- getTheatreType()
- displayShowtime()
- getMemberDetails()
- printMemberBenefits()

4. Create another for loop and do the following for each member in movieMembershipArray:
- purchase a movie ticket for “Everything Everywhere All At Once” with the standard theatre
type at 11:25 AM for $6.99
- set snacks to “Oh Henry”
- print getMemberDetails()

5. Invoke accessVIPLounge() method for the myGold object to prompt the user to enter their password.

6. Invoke purchaseAlcohol() method for myGold and output if the purchase was successful. Call the
getMemberDetails () method for myGold and print the information to the screen.

7. Purchase a movie ticket for mySilver and enter the following information:
- price: $7.89, next Movie: “Top Gun: Maverick”, theatre type: standard, show hour: 14, show
Minutes: 25, snacks: Smarties
8. Purchase a movie ticket for myGold and enter the following information:
- price: $15.98, next Movie: “The Black Phone”, theatre type: standard, show hour: 13, show
Minutes: 50, snacks: Kitkat

9. Purchase a movie ticket for myIMAX and enter the following information:
- price: $14.50, next Movie: “Elvis”, theatre type: IMAX, show hour: 15, show Minutes: 0, snack:
Gummies

10. Call getMemberDetails() for all three objects and print the returned values to the screen.

Sample Output:
Member Name: James Kelly
Member Rank: Silver
Points: 0
Next Movie: Sonic The Hedgehog 2
Theatre type: standard
Showtime: 14:30
Snack: gummy bears
This membership card belongs to James Kelly. They have 0 points. Their next movie is
Sonic The Hedgehog 2 at 14:30 with a standard screening. They will be having gummy
bears as a snack. They have Silver membership.
Discount rate = 10.0%
Points gained per dollar = 1.2

Member Name: Berry Rich


Member Rank: Gold
Points: 50
Next Movie: Jurassic World Dominion
Theatre type: standard
Showtime: 18:45
Snack: popcorn
This membership card belongs to Berry Rich. They have 50 points. Their next movie is
Jurassic World Dominion at 18:45 with a standard screening. They will be having
popcorn as a snack. They have Gold membership. and VIP privileges.
Discount rate = 25.0%
Points gained per dollar = 2.0

Member Name: David Stu


Member Rank: IMAX
Points: 25
Next Movie: Thor: Love And Thunder
Theatre type: IMAX
Showtime: 10:0
Snack: nachos
This membership card belongs to David Stu. They have 25 points. Their next movie is
Thor: Love And Thunder at 10:0 with a IMAX screening. They will be having nachos as a
snack. They have IMAX membership.
Discount rate = 50.0%
Points gained per dollar = 1.3
The movie Everything Everywhere All At Once has been purchased by James Kelly for
6.291 and will be showing at 11:25 with standard screening. They have earned 8 points

This membership card belongs to James Kelly. They have 8 points. Their next movie is
Everything Everywhere All At Once at 11:25 with a standard screening. They will be
having Oh Henry as a snack. They have Silver membership.

The movie Everything Everywhere All At Once has been purchased by Berry Rich for
5.2425 and will be showing at 11:25 with standard screening. They have earned 13
points

This membership card belongs to Berry Rich. They have 63 points. Their next movie is
Everything Everywhere All At Once at 11:25 with a standard screening. They will be
having Oh Henry as a snack. They have Gold membership. and VIP privileges.

The movie Everything Everywhere All At Once has been purchased by David Stu for 6.99
and will be showing at 11:25 with standard screening. They have earned 0 points

This membership card belongs to David Stu. They have 25 points. Their next movie is
Everything Everywhere All At Once at 11:25 with a standard screening. They will be
having Oh Henry as a snack. They have IMAX membership.

Please enter your password


4562
Access granted!
Enjoy your beverage.

This membership card belongs to Berry Rich. They have 63 points. Their next movie is
Everything Everywhere All At Once at 11:25 with a standard screening. They will be
having alcohol as a snack. They have Gold membership. and VIP privileges.

The movie Top Gun: Maverick has been purchased by James Kelly for 7.101 and will be
showing at 14:25 with standard screening. They have earned 9 points

The movie The Black Phone has been purchased by Berry Rich for 11.985 and will be
showing at 13:50 with standard screening. They have earned 31 points

The movie Elvis has been purchased by David Stu for 7.25 and will be showing at 15:0
with IMAX screening. They have earned 18 points

This membership card belongs to James Kelly. They have 17 points. Their next movie is
Top Gun: Maverick at 14:25 with a standard screening. They will be having Smarties as
a snack. They have Silver membership.

This membership card belongs to Berry Rich. They have 94 points. Their next movie is
The Black Phone at 13:50 with a standard screening. They will be having Kitkat as a
snack. They have Gold membership. and VIP privileges.

This membership card belongs to David Stu. They have 43 points. Their next movie is
Elvis at 15:0 with a IMAX screening. They will be having Gummies as a snack. They
have IMAX membership.
Submission:
Please submit all six java file into the FOL submission drop box labelled Assignment Three. Make sure
you submit the .java file and not the .class file

Rubric (24 marks)


Criteria Excellent Good Poor
2 1 0
Documentation Code has a comment header Code has a header No comment
clock at the top of the file listing block but not all header is
program name, programmer, information is provided.
date, and purpose. presented.
Naming Proper naming convention is Proper naming No naming
Convention & followed, and comments are convention is mostly convention is
Comments used throughout the program followed. followed, and no
to explain what is happening. Comments are used comments are
Documentation headers sparingly. included.
included on all methods that
should have them.
MovieMembership MovieMembership class follows MovieMembership MovieMembership
Class document specifications (All class follows most class meets very
variables and methods have document little or none of
appropriate visibility modifiers, specifications. the document
constructor methods set the specifications.
correct values, all methods
perform the correct functions).
SilverMember SilverMember class follows SilverMember class SilverMember
Class document specifications (All meets most document class meets very
variables and methods have specifications. little or none of
appropriate visibility modifiers, the document
constructor methods set the specifications.
correct values, all methods
perform the correct functions).
VIPPrivilege VIPPrivilege interface follows VIPPrivilege interface VIPPrivilege meets
Interface document specifications. meets most document very little or none
specifications. of the document
specifications.
GoldMember Class GoldMember class follows GoldMember class GoldMember class
document specifications (All meets most document meets very little or
variables and methods have specifications. none of the
appropriate visibility modifiers, document
constructor methods set the specifications.
correct values, all methods
perform the correct functions).
IMAXMember IMAXMember class follows IMAXMember class IMAXMember
Class document specifications (All meets most document class meets very
variables and methods have specifications. little or none of
appropriate visibility modifiers, the document
constructor methods set the specifications.
correct values, all methods
perform the correct functions).
Object Objects are created as specified Objects are not created No Objects of the
Instantiation (Step in the document. to document member classes
1 & 2) specifications. are created.
Polymorphism All methods in step 3 are tested Not all specified Very little or none
(Step 3) for each object and display methods are invoked or of the methods are
correct information. don’t display the invoked.
correct information.
Purchasing Tickets All membership objects test the Not all specified Methods are not
and Setter methods for purchasing a new methods are tested, or invoked or
Methods (Step 4) ticket and setting new snacks. the information displayed to the
The information is displayed to displayed is not correct screen.
the screen with the correct according to the specs.
information.
Interface Testing Interface methods have been Interface methods have Interface methods
(Step 5-6) properly implemented and somewhat been have not been
tested. Correct information is properly implemented implemented and
displayed. and tested. tested.
Final output (Steps Objects follow the proper steps Objects somewhat Objects somewhat
7-10) for purchasing the final tickets follow the proper steps follow the proper
and display the correct for purchasing the final steps for
information to the screen. tickets. purchasing the
final tickets.

You might also like