INFO6121 Assignment #3: "If Your Code Fails To Compile You Will Be Assigned A Mark of 0" Instructions
INFO6121 Assignment #3: "If Your Code Fails To Compile You Will Be Assigned A Mark of 0" Instructions
INFO6121 Assignment #3: "If Your Code Fails To Compile You Will Be Assigned A Mark of 0" Instructions
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()
“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”
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.
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.
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
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.
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