Study the following class diagram, additional information and answer the questions that follow:
MovieTicket
|
movieName: string
TicketPrice: double
TicketsSold: int
donation[100]: double
totalCnt: int
|
MovieTicket();
getName():string
getTicketPrice():double
getnoOfTicketsSold():int
setName(string): void
setTicketPrice(double): void
setnoOfTicketsSold(int): void
computeDonation(int): void
writeFile():void
|
Additional Information:
MovieTicket is a class written to fulfil the requirements of making 100 donations to charity from the ticket sales. The donation is derived from 10% of the ticket sales. The donations are written to a file.
(a) Write the class specification for MovieTicket.
(b) Write code to implement the following for MovieTicket:
(i) Constructor, Assessors and Mutators
(ii) computeDonation method
(iii) writeFile method
(c) Write a test driver to test ALL the methods written in Part (b). The program uses a loop to repeat 100 times to obtain input (movie name, tickets sold and ticket price) from user and invokes the respective methods to set the values and computes the donation. After the loop, the contents of donation array are written to a file using the writeFile method. Include a screen output in your submission.