Lab 7: De ning Classes and Methods Solved

20.00 $

Categories: , Tags: , , , , , , ,
Click Category Button to View Your Next Assignment | Homework

You'll get a download link with a: zip solution files instantly, after Payment

Securely Powered by: Secure Checkout

Description

5/5 - (1 vote)

Lab 7: De ning Classes and Methods

Abstract
Your task is to complete two problems from the textbook. These problems are easier than they appear at the rst glance if you remember to focus on each individual method you need to write as its own

De ne a Trivia class that contains information about a single trivia question. The question and answer should be de ned as instance variables of type String. Create accessor and mutator methods. In your main method, create
two trivia objects with questions and answers of your choice. Then for each Trivia object, have your program ask the question, input an answer, compare the typed answer to the actual to the actual answer, and output if the user’s
answer was correct or incorrect.

2 Assignment 2
Consider a class ConcertPromoter that records the tickets sold for a performance. Before the day of the concert, tickets are sold only over the phone.
Sales on the day of the performance are made only in person at the concert venue. Tickets cost more at the venue than at over the phone, naturally.
The class has the following attributes:
 The name of the band
 The capacity of the venue (the number of seats)
 The number of tickets sold
 The price of a ticket sold by phone
 The price of a ticket sold at the venue in person
It has methods which:
 Record the sale of one or more tickets
 Change from selling by phone to selling at the venue (hint, do you
need another instance variable)
 Return the number of tickets sold
 Return the number of tickets remaining
 Return the total sales for the concert
Implement ConcertPromoter and write a program that uses it to record the sales for a concert. Your program should record phone sales, then sales at the venue. As tickets are sold, the number of seats remaining should be
displayed. At the end of the program, display the number of tickets sold and the total sales amount for the concert.

  • Lab7.zip