Lab 7: De ning Classes and Methods
AbstractYour 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, createtwo 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 usersanswer was correct or incorrect.
2 Assignment 2Consider 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 personIt has methods which: Record the sale of one or more tickets Change from selling by phone to selling at the venue (hint, do youneed another instance variable) Return the number of tickets sold Return the number of tickets remaining Return the total sales for the concertImplement 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 bedisplayed. At the end of the program, display the number of tickets sold and the total sales amount for the concert.
Reviews
There are no reviews yet.