Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 1: G OLANG Language We ask you to create a program that lets us manage the sale of theater tickets. The name and type

Question 1: GOLANG Language

We ask you to create a program that lets us manage the sale of theater tickets. The name and type are given in italic.

  1. Create struc Play with:

    • a string for the name (name) of the theater piece,

    • a slice of Tickets containing bought tickets (purchased),

    • a Time.time for the date of the first representation (showStart),

    • a Time.time for the date of the last representation (showEnd).

  2. Create struc Comedy and struc Tragedy with the following attributes. (default parameters are given in parenthesis). These structures contain embedded type Play.

    • a float32 for the number of laughs (laughs) per minute. (0.2, and 0.0).

    • an int32 for the number of deaths (deaths) in the piece. (0 and 12).

    • Depending on the type, the attributes of the embedded structure Play will have the different default values.

      1. name (Tartuffe, Macbeth)

      2. purchased (0,0)

      3. showStart (Mar. 3rd at 4:00 pm April 16th at 9:30 am)

      4. showEnd (Mar 3ed at 5:20 pm, April 16th at 12:30 pm)

  3. Create the interface Show which can be used by struc Comedy and struc Tragedy and imposing the following methods:

    • GetName() (string),

    • GetShowStart() (time.Time),

    • GetShowEnd() (time.Time),

    • AddPurchase (*Ticket) (bool), which lets us add a ticket to the slice of Tickets (returns false if a ticket with the same seat number was already bought),

    • IsNotPurchased (*Ticket) (bool), which returns true if a ticket with the seat number has not yet been sold.

  4. Create struc Seat with the following attributes (default values between brackets):

    • a int32 for the seat number (number) [1],

    • a int32 for the seat row (number) [1],

    • a *Category called cat representing the category of the seat.

  5. Create struc Category with the following attributes:

    • a const string for the name of the category (name) which can be Prime, Standard, Special

    • a float32 for the base price of the category (base) [25.0].

  6. Create struc Ticket with:

    • a string representing the number of spectators (customer),

    • a *Seat pointing to the chosen seat (siege),

    • a *Show pointing to the show (s).

  7. Create struc Theater with:

    • a slice of Seat containing all seats in the theater

    • a slice of Show giving a list of shows to come.

  8. Define following functions:

    • NewSeat with argument the number and row, as well as the category of the seat.

    • NewTicket taking an argument the name of a spectator and pointer to a seat as well as to a piece.

    • NewTheater taking the argument an int32 specifying the number of the seat, an int32 for the number of rows and a slice of Shows.

Finally, create the function main constructing a theater of 25 seats split in 5 rows. (row 1 is at the front).

The first row is categorised as Prime, the rows 2 to 4 are Standard and the fifth row is Special.

The theater will present a Comedy on March 3rd 2020 from 7:30pm to 10:00pm and a Tragedy April 10th 2020 from 8:00pm to 11:00pm. The prices for the tickets are:

Prime 25$.

Standard 25$

Special 15$

Once all structures are initialised, go on an infinite loop to sell tickets for the two pieces. You should ask which piece, category and number of seat. If the seat is already taken, your program should propose another seat in the same category if available and in another if not. Only one ticket can be bought at a time.

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

Step: 3

blur-text-image

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

Microsoft SQL Server 2012 Unleashed

Authors: Ray Rankins, Paul Bertucci

1st Edition

0133408507, 9780133408508

More Books

Students also viewed these Databases questions