COMP 1030 Assignment #6 September 2021 StaticMethods-MethodOverloading During this lab you will build two java classes.The first
Question:
COMP 1030 Assignment #6 September 2021
StaticMethods-MethodOverloading
During this lab you will build two java classes.The first class will contain the required state andbehaviour for the object but NO main method.The second class will contain simply the main method togive the JRE an entry point into the program, a line to instantiate a new object based upon the first classandafewlines toexercise thefunctionalityofthefirst class.
Whenwritingyourcode,keeptheseguidelinesinmind:
- Starteachclasswiththeproperjavadoccommentheader.Thefirstlineofthatcommentshouldbethe purpose oftheclassnot justits name.
- Provideacommentfor eachsection ofcode.
- Followthelayoutforyourclassasillustratedbelow:
Javadoc comment headerImportstatements(ifrequired)Classdeclaration
State (instance variables/data)Constructor(s) (if required)Behaviour(s)(method(s))
Closeclassdeclaration
- Usewhitespaceandindentationstomakeyourcodemorereadableandeasytodebug.
- Besuretoclearlyunderstandyourwork-donotsimplycopycodefromsomeoneelse.
- Followallcoursecodingandnamingconventions.
Instructions:
Step1Writeajavaclassthatadherestothefollowingcriteria:
- Create a class calledMovieTicketthat will serve as a blueprint for a movie ticket.(thereforecontainsnomainmethod).
- Thisclassshouldhave:
- Thefollowing 4States:moviename, ticketnumber,theatrenumber, ticket price. Ticket price should be declared as public static. Static variables are public since will access it directly in the test class using the class name : MovieTicket.ticketPrice
- Settersandgettersforeachinstancevariable. Ticket price doesnt have getters and setters. We access it directly with the class name. Its public and static
- A default constructor
- A parametrized constructor, doesnt include the variable ticket price. Its is not an instance variable
- Write a method checkPalindromthat checks if movienameis a Palindrome.A palindrome reads same from front and back e.g.- aba, ccaacc, mom, etc. If it is, it converts it to uppercase and return the string in uppercase, otherwise it returns the string "Not A Palindrom".
- AstaticvariablecalledticketPricewithahardcodedinitialvalue.
- Astaticmethod calculateTaxwhichcalculatesandreturnsthetax$amountontheticketprice(assume13%tax). The method should be declared as public static and will be called directly in the test class using the class name : MovieTicket.calculateTax
- Two non-static overloaded methods inquireMovieRunDates which will return the movie run dates, one based upon themoviename :
"Die Hard 1" :"Jan 1,Jan 2, Jan 3";
"Die Hard 2":"Jan 4,Jan 5, Jan 6";
"Die Hard 3":"Jan 7,Jan 8, Jan 9";
"Die Hard 4":"Jan 10,Jan 11, Jan 12";
add a default case
andone basedupontheticket number,
12345 :"Jan 1,Jan 2, Jan 3";
12346:Jan 4,Jan 5, Jan 6";
12347:Jan 7,Jan 8, Jan 9";
12348:"Jan 10,Jan 11, Jan 12";
add a default case
Usetheswitchstatementtohardcode the4differentoptionsforeachmethod.
- Create a second class called MovieTicketTestHarness which contains a main methodto test thefirstclass:
- Note:Anyinteractionwiththeusermustbeaccompaniedwithanappropriatemessage.
- Instantiateaticket.
- Capture information from the user, and use the setters to populate all of the non-static fieldsoftheticket.
- Printoutallthefieldsoftheticketplusthepriceoftheticketandthetaxportionoftheticket.
- Asktheuserforamovie name,usetheappropriatemethodtodetermineandprintthemovierundates.
- Ask the user for a ticket number, use the appropriate method to determine and print the movierundates.
- Call the method isPalindrom and print the result.
- Note:Anyinteractionwiththeusermustbeaccompaniedwithanappropriatemessage.
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill