Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please convert this to c# and please answer with the code and output, positive feedback will be left. Thanks public abstract class Ticket { private

Please convert this to c# and please answer with the code and output, positive feedback will be left. Thanks public abstract class Ticket { private int ticketNumber; private static int NextTicketNumber=1; public Ticket() { ticketNumber = NextTicketNumber; NextTicketNumber++; } /** * * @return the ticket price */ public abstract double getPrice(); @Override public String toString() { return getClass().getSimpleName()+", Ticket Number: "+ticketNumber+", Price: $"+String.format("%.2f",getPrice()); } } 
public class CurrentBookings extends Ticket { public CurrentBookings() { super(); } @Override public double getPrice() { return 75; } } 
public class AdvancedBookings extends Ticket{ private int NoOfDays; public AdvancedBookings(int days) { super(); NoOfDays = days; } @Override public double getPrice() { if(NoOfDays<15) return 50; else return 25; } } 
public class DiscountBooking extends Ticket{ private int NoOfDays; public DiscountBooking(int days) { super(); NoOfDays = days; } @Override public double getPrice() { if (NoOfDays>=1) return 10; else return 75; } } 
import java.util.ArrayList; import java.util.Scanner; public class PurchaseTicket { public static void main(String[] args) { ArrayList tickets = new ArrayList<>(); Scanner input = new Scanner(System.in); int choice=0, days; do { menu(); choice = input.nextInt(); switch (choice) { case 1: tickets.add(new CurrentBookings()); break; case 2: System.out.print(" how many days in the future the game is: "); days = input.nextInt(); if(days==0) tickets.add(new CurrentBookings()); else tickets.add(new AdvancedBookings(days)); break; case 3: System.out.print(" how many days in the future the game is: "); days = input.nextInt(); tickets.add(new DiscountBooking(days)); break; case 4: for (Ticket ticket:tickets ) { System.out.println(ticket); } break; case 5: System.out.println("Thanks for using this app...."); break; default: System.out.println("Wrong choice... please try again..."); } }while (choice!=5); } public static void menu() { System.out.print(" 1. Sell a Ticket for todays game" + " 2. Sell a Ticket for a future game " + " 3. Sell a Discount Ticket " + " 4. Print All Tickets " + " 5. Exit " + "Enter Choice: "); } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Server Query Performance Tuning

Authors: Sajal Dam, Grant Fritchey

4th Edition

1430267429, 9781430267423

More Books

Students also viewed these Databases questions

Question

What were the issues and solutions proposed by each team?

Answered: 1 week ago

Question

What are Measures in OLAP Cubes?

Answered: 1 week ago

Question

How do OLAP Databases provide for Drilling Down into data?

Answered: 1 week ago

Question

How are OLAP Cubes different from Production Relational Databases?

Answered: 1 week ago