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?
-
Shade asked Dow to give him a check for $100 in return for Shades delivery the next day of a television set. Dow gave the check, but Shade never delivered the television set. Does Dow have a defense...
-
Anthony Romeo was an openly gay student at Seton Hall, a Catholic university. He claimed that he elected to attend Seton Hall in part because of its published antidiscrimination policy. In 2003, he...
-
In the event that a series converges uniformly, one can consider the derivative of the series to arrive at the summation of other infinite series. a. Differentiate the series representation for...
-
Ling Company reports the following information for the year ended December 31, 2014: sales revenue $1,000,000, cost of goods sold $700,000, operating expenses $200,000, and an unrealized gain on...
-
Tony's favorite memories of his childhood were the times he spent with his dad at camp. Tony was daydreaming of those days a bit as he and Suzie jogged along a nature trail and came across a...
-
Read the article " What's Wrong with Trade Sanctions ". While you are reading, outline the author's argument against trade barriers and answer the questions following the timeline. Number your...
-
The profits of last three years are Rs.42, 000; Rs.39, 000 and Rs.45, 000. Find out goodwill of 2 years purchase. A B C D Rs.42, 000 Rs.84, 000 Rs. 1, 26,000 Rs.36, 000
-
Henderson Industries has a bond outstanding with a 15-year maturity, a 15% annual coupon rate, and a $1,000 par value. The bond has a 9% yield to maturity, but it can be called in 6 years at a price...
-
Payments with periodic rates. Denise has her heart set on being a millionaire. What payment does Denise need to make at the end of each month over the coming 38 years at 9% APR to reach her...
-
Braxton Enterprises currently has debt outstanding of $38 million and an interest rate of 9%. Braxton plans to reduce its debt by repaying $9 million in principal at the end of each year for the next...
-
Discuss what specifically motivates you at work or at school. Think specifically about a time where you really put a lot of energy into a task. Why did you work so hard? What do you think you were...
-
Old Country Links, Incorporated, produces sausages in three production departments-Mixing, Casing and Curing, and Packaging. In the Mixing Department, meats are prepared and ground and then mixed...
-
a ) Define the following terms; i ) grain, ii ) grain boundary, iii ) phase, iv ) solid solution b ) What is the difference of compounds, alloys and intermetallics? c ) Examine the unlimited solid...
-
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
-
1.7 Limitations of Comparative Advantage. The key to understanding most theories is what they say and what they don't. Name four or five key limitations to the theory of comparative advantage.
-
1.6 Post-LIBOR Scandal. Why do you think the UK government has resolved against the total elimina- tion of LIBOR benchmarks after the scandal?
-
1.9 Aidan's Globalization. After reading the chapter's description of Aidan's globalization process, how would you explain the distinctions between interna- tional, multinational, and global...
Study smarter with the SolutionInn App