Question: Here is pseudocode that goes inside the method: Method header: public ConcertTicket remove() { // Create a ConcertTicket reference variable (DO NOT create a new
Here is pseudocode that goes inside the method:
Method header:
public ConcertTicket remove() {
// Create a ConcertTicket reference variable (DO NOT create a new ConcertTicket JUST create the reference variable)
ConcertTicket ticket = null;
if (this.size > 0) {
// TODO Use the size variable (which always points at the next empty
// slot) to get the last added ConcertTicket from the array:
// TODO Set that array slot to null:
// TODO Decrement the size variable:
}
// Return the ConcertTicket:
return ticket;
}
4. Your job is to write a method that removes a ConcertTicket from the wallet and returns it. The method should be called remove. It should take no parameters, but it should return the most recently added Concert Ticket. Here is pseudocode that goes inside the method: Method header: public ConcertTicket remove() { // Create a ConcertTicket reference variable (DO NOT create a new Concert Ticket - JUST create the reference variable) ConcertTicket ticket = null; if (this.size > 0) { // TODO Use the size variable (which always points at the next empty // slot) to get the last added Concertticket from the array: // TODO Set that array slot to null: // TODO Decrement the size variable: } // Return the ConcertTicket: return ticket; 3
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
