Question: package ConcertTicket; import java.util.Arrays; / * * * This class iallet which can store any number of concert tickets. * * @version Fall 2 0
package ConcertTicket;
import java.util.Arrays;
This class iallet which can store any number of concert tickets.
@version Fall
public class Wallet
Array of ConcertTicket objects
protected ConcertTicket tickets new ConcertTicket;
private int size ;
Add a concert ticket into the array
@param ct a concert ticket being added to the wallet
public void addConcertTicket ct
if thissize this.tickets.length
this.resize;
this.ticketsthissize ct;
this.size;
Resizes the wallet so that you can fit more tickets.
public void resize
this.tickets Arrays.copyOfthistickets, this.tickets.length;
Converts the wallet into a string representation for easy reading.
@return a string representation of the wallet
@Override
public String toString
return Arrays.toStringArrayscopyOfthistickets, size;
Returns how many tickets are in the wallet.
@return the size of the wallet
public int getSize
TODO: Implement getSize
return this.size;
Returns the size of the wallet.
@return the size of the wallet
public int getLength
TODO: Implement getLength
return ;
Removes the most recently added concert ticket from the wallet
@return the concert ticket removed from the wallet
public ConcertTicket remove
TODO: Create a ConcertTicket reference variable DO NOT create a
new ConcertTicket JUST create the reference variable
new ConcertTicket;
if thissize
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:
TODO: Return the ConcertTicket:
return null;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
