2.2. Write a class called Ticket that has the following: A field cost for the...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
2.2. Write a class called Ticket that has the following: • A field cost for the price of the ticket and a string field time for the start time of the event (assume times are in 24-hour format, like '18:35') . • A constructor that sets those variables •A_str_() method that returns a string of the form Ticket(<cost>, <time>), where <cost> and <time> are replaced with the values of the cost and time fields. • A method called is_evening_time() that returns True or False, depending on whether the time falls in the range from 18:00 to 23:59. • A method called bulk_discount() that takes an integer n and returns the discount for buying n tickets. There should be a 10% discount for buying 5 to 9 tickets, and a 20% discount for buying 10 or more. Otherwise, there is no discount. Return these percentages as integers. Test the class by creating a Ticket item, printing it, calling the is_evening_time() method, and calling the bulk_discount() method. 2.2. Write a class called Ticket that has the following: • A field cost for the price of the ticket and a string field time for the start time of the event (assume times are in 24-hour format, like '18:35') . • A constructor that sets those variables •A_str_() method that returns a string of the form Ticket(<cost>, <time>), where <cost> and <time> are replaced with the values of the cost and time fields. • A method called is_evening_time() that returns True or False, depending on whether the time falls in the range from 18:00 to 23:59. • A method called bulk_discount() that takes an integer n and returns the discount for buying n tickets. There should be a 10% discount for buying 5 to 9 tickets, and a 20% discount for buying 10 or more. Otherwise, there is no discount. Return these percentages as integers. Test the class by creating a Ticket item, printing it, calling the is_evening_time() method, and calling the bulk_discount() method.
Expert Answer:
Answer rating: 100% (QA)
class Ticket def initself cost time selfcost cost selftime time def strself return Ticketcost0 time1... View the full answer
Related Book For
Building Java Programs A Back To Basics Approach
ISBN: 9780135471944
5th Edition
Authors: Stuart Reges, Marty Stepp
Posted Date:
Students also viewed these electrical engineering questions
-
In this lab you will write a class called Time. The Time class will have three data members: hours, minutes, and seconds (all ints). Times will be stored using a 24 hour clock, so 10 AM is stored as...
-
An importer operates a small warehouse that has the following annual costs. Wages for purchasing are $45,000, purchasing expenses are $30,000, customs and brokerage costs are $30 per order, the cost...
-
The Norton Company produces a product that has the following sales expectations for 2007: Sales ($) May 150,000 June 150,000 July 300,000 August 450,000 September 600,000 October 300,000 November...
-
The word culture is used in many ways, such as when people talk about national culture, organisational culture, political culture or youth culture. In which ways do the meanings of culture differ?
-
In-the-Box Retail Corporation reported stockholders equity on its balance sheet at December 31, as follows: In-the-Box Retail Balance Sheet (Partial) Shareholder s Equity: Common stock, $1.00 par...
-
What is a data structure? List several types of common data structures.
-
What is the scope of the discovery?
-
The rectangular loop shown in Fig. is pivoted about the y-axis and carries a current of 15.0 A in the direction indicated. (a) If the loop is in a uniform magnetic field with magnitude 0.48 T in the...
-
2. You and your son are prisoners at a concentration camp. Your son tried to escape but was recaptured and sentenced to hang at the gallows. To send a message to all others who may try to escape, the...
-
Assume that you have some shares of stock in ABC Inc. Why do we say that if you also purchase a put option on the same stock, the price paid to buy the put option is like paying an insurance premium?
-
What account type is this T-account? Equipment Date Debit Date Credit Jul 01 7,040 Balance 7,040
-
3. (3 marks) Suppose that the universal set for variable x is Z. Let P(x) be the predicate 0 < x <60, let Q(x) be the predicate +5
-
You are asked to watch the video, Boolean Simplification using Karnaugh Map (Credit: ENGRTUTOR) which is found on the CLMS week 5 section of the course, and answer the following question: For the...
-
Sam's Shirts Inc. is a custom t-shirt company with current period sales of $250,000. Assuming Sam's has $190,000 of t-shirts available for sale and an expected gross margin ratio of 30%, estimate the...
-
Rewrite the following partial EBNF grammar in BNF notation. You are allowed to create new non-terminals in order to define the LHS non-terminals properly. You do not need to create rules for the...
-
b) The following are the two Maxwell equations related to electrostatic V.D=p; Vx=-=0 t i) State the relationship between electric flux density, D and electric field intensity, E [2 marks] ii) Given...
-
As of January 1, 2018, Room Designs, Inc. had a balance of $9,900 in Cash, $3,500 in Common Stock, and $6,400 in Retained Earnings. These were the only accounts with balances in the ledger on January...
-
What is the difference between the public and private keywords? What items should be declared private?
-
Write the result of each expression. Note that a variables value changes only if you reassign it using the = operator. double grade = 2.7; Math.round (grade); // grade grade = Math.round (grade); //...
-
Convert each of the following decimal numbers into its equivalent binary number: a. 6 b. 44 c. 72 d. 131
-
Winfred Metal Reclamation Ltd, a small company, buys scrap metal residues from local companies and treats the residues to recover the metal which is then sold to other local companies. The company is...
-
What financial statements must be prepared?
-
Mainbrace Ltd is a book publisher and retailer which trades via the Internet. The company was formed using a kit bought from a legal stationer, start up capital was provided by the major shareholder,...
Study smarter with the SolutionInn App