5. For the next four problems, consider the task of representing types of tickets to campus events. Each ticket has a unique number and a price. There are three types of tickets: walk-up tickets, advance tickets, and student advance tickets. Figure 9.10 illustrates the types: • Walk-up tickets are purchased the day of the event and cost $50. • Advance tickets purchased 10 or more days before the event cost $30, and advance tickets purchased fewer than 10 days before the event cost $40. • Student advance tickets are sold at half the price of normal advance tickets: When they are purchased 10 or more days early they cost $15, and when they are purchased fewer than 10 days early they cost $20. Implement a class called Ticket that will serve as the superclass for all three types of tickets. Define all common operations in this class, and specify all differing operations in such a way that every subclass must implement them. No actual objects of type Ticket will be created: Each actual ticket will be an object of a subclass type. Define the following operations: • The ability to construct a ticket by number. • The ability to ask for a ticket's price. • The ability to println a ticket object as a String. An example String would be "Number: 17, Price: 50.0". 644 Walkup Ticket Ticket number Ticket(number) getPrice() toString() Advance Ticket Student Advance Ticket Figure 9.10 Classes of tickets that are available to campus events Chapter 9 Inheritance and Interfaces
5. For the next four problems, consider the task of representing types of tickets to campus events. Each ticket has a unique number and a price. There are three types of tickets: walk-up tickets, advance tickets, and student advance tickets. Figure 9.10 illustrates the types: • Walk-up tickets are purchased the day of the event and cost $50. • Advance tickets purchased 10 or more days before the event cost $30, and advance tickets purchased fewer than 10 days before the event cost $40. • Student advance tickets are sold at half the price of normal advance tickets: When they are purchased 10 or more days early they cost $15, and when they are purchased fewer than 10 days early they cost $20. Implement a class called Ticket that will serve as the superclass for all three types of tickets. Define all common operations in this class, and specify all differing operations in such a way that every subclass must implement them. No actual objects of type Ticket will be created: Each actual ticket will be an object of a subclass type. Define the following operations: • The ability to construct a ticket by number. • The ability to ask for a ticket's price. • The ability to println a ticket object as a String. An example String would be "Number: 17, Price: 50.0". 644 Walkup Ticket Ticket number Ticket(number) getPrice() toString() Advance Ticket Student Advance Ticket Figure 9.10 Classes of tickets that are available to campus events Chapter 9 Inheritance and Interfaces
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
Please help me out with this java problem! Thanks!
![5. For the next four problems, consider the task of representing types of tickets to campus events. Each ticket has a
unique number and a price. There are three types of tickets: walk-up tickets, advance tickets, and student advance
tickets. Figure 9.10 illustrates the types:
• Walk-up tickets are purchased the day of the event and cost $50.
• Advance tickets purchased 10 or more days before the event cost $30, and advance tickets purchased fewer than
10 days before the event cost $40.
• Student advance tickets are sold at half the price of normal advance tickets: When they are purchased 10 or more
days early they cost $15, and when they are purchased fewer than 10 days early they cost $20.
Implement a class called Ticket that will serve as the superclass for all three types of tickets. Define all common
operations in this class, and specify all differing operations in such a way that every subclass must implement them.
No actual objects of type Ticket will be created: Each actual ticket will be an object of a subclass type. Define the
following operations:
• The ability to construct a ticket by number.
• The ability to ask for a ticket's price.
• The ability to println a ticket object as a String. An example String would be "Number: 17, Price: 50.0".
644
Walkup Ticket
Ticket
number
Ticket(number)
getPrice()
toString()
Advance Ticket
Student Advance Ticket
Figure 9.10 Classes of tickets that are available to campus events
Chapter 9 Inheritance and Interfaces
6. Implement a class called walkupTicket to represent a walk-up event ticket. Walk-up tickets are also constructed by
number, and they have a price of $50.
7. Implement a class called AdvanceTicket to represent tickets purchased in advance. An advance ticket is con-
structed with a ticket number and with the number of days in advance that the ticket was purchased. Advance tickets
purchased 10 or more days before the event cost $30, and advance tickets purchased fewer than 10 days before the
event cost $40.
8. Implement a class called Student Advance Ticket to represent tickets purchased in advance by students. A student
advance ticket is constructed with a ticket number and with the number of days in advance that the ticket was pur-
chased. Student advance tickets purchased 10 or more days before the event cost $15, and student advance tickets
purchased fewer than 10 days before the event cost $20 (half of a normal advance ticket). When a student advance
ticket is printed, the String should mention that the student must show his or her student ID (for example,
"Number: 17, Price: 15.0 (ID required)").](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F03ad3f41-6abd-4c87-9649-36856dac78a8%2Fc31ce365-44f3-48c7-899c-ee4cd63bf7f2%2Fgxl2scg_processed.png&w=3840&q=75)
Transcribed Image Text:5. For the next four problems, consider the task of representing types of tickets to campus events. Each ticket has a
unique number and a price. There are three types of tickets: walk-up tickets, advance tickets, and student advance
tickets. Figure 9.10 illustrates the types:
• Walk-up tickets are purchased the day of the event and cost $50.
• Advance tickets purchased 10 or more days before the event cost $30, and advance tickets purchased fewer than
10 days before the event cost $40.
• Student advance tickets are sold at half the price of normal advance tickets: When they are purchased 10 or more
days early they cost $15, and when they are purchased fewer than 10 days early they cost $20.
Implement a class called Ticket that will serve as the superclass for all three types of tickets. Define all common
operations in this class, and specify all differing operations in such a way that every subclass must implement them.
No actual objects of type Ticket will be created: Each actual ticket will be an object of a subclass type. Define the
following operations:
• The ability to construct a ticket by number.
• The ability to ask for a ticket's price.
• The ability to println a ticket object as a String. An example String would be "Number: 17, Price: 50.0".
644
Walkup Ticket
Ticket
number
Ticket(number)
getPrice()
toString()
Advance Ticket
Student Advance Ticket
Figure 9.10 Classes of tickets that are available to campus events
Chapter 9 Inheritance and Interfaces
6. Implement a class called walkupTicket to represent a walk-up event ticket. Walk-up tickets are also constructed by
number, and they have a price of $50.
7. Implement a class called AdvanceTicket to represent tickets purchased in advance. An advance ticket is con-
structed with a ticket number and with the number of days in advance that the ticket was purchased. Advance tickets
purchased 10 or more days before the event cost $30, and advance tickets purchased fewer than 10 days before the
event cost $40.
8. Implement a class called Student Advance Ticket to represent tickets purchased in advance by students. A student
advance ticket is constructed with a ticket number and with the number of days in advance that the ticket was pur-
chased. Student advance tickets purchased 10 or more days before the event cost $15, and student advance tickets
purchased fewer than 10 days before the event cost $20 (half of a normal advance ticket). When a student advance
ticket is printed, the String should mention that the student must show his or her student ID (for example,
"Number: 17, Price: 15.0 (ID required)").
Expert Solution
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 6 steps with 8 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Recommended textbooks for you
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY