QuestionQuestion

BoardingGroup Class
Create a new java class called BoardingGroup. This is an instantiable class that will be used to represent groups entering the ride line. Each boarding group object will have a name and a number of people in the group. You will need to write a basic constructor for the object as well as accessors for all of the class' fields. The names of these methods should follow standard.

3 Ride Queue: Set-Up
Now, it is time to start creating the queue for the boarding groups. You will be using a linked list implementation to create the queue. Add the following class to your Java project that will be used as the linked list nodes of the queue: BGNode.java. Create a new java class called RideQueue for the queue. This will be a queue of boarding groups and must implement the following interface: QueueADT.java.

3.1 Fields & Constructor
Your RideQueue class should have five private fields with names and data types as follows:
• BGNode: front, back
• int: capacity, numOfPeople, numOfGroups
Note that here, the capacity field is the max number of people that can fit into the queue. After you have added the fields to your class, implement the constructor as described in this javadoc. 3.2 Other Preliminary Methods
There are two other simple methods that should be implemented at this time as they may be helpful in the implementation of other methods. Implement the size() and isEmpty() methods as described in this javadoc.
Then you can add the following toString() to your RideQueue class. You may find that it proves helpful when debugging your code.

4 Entering the Queue: Enqueue
Now it is time to be able to add groups to the ride’s queue. Since the queue has a max capacity of people it can hold, sometimes certain groups may not be able to enter the queue. To do this, implement the enqueue() method as described in this javadoc.
Once you are confident you have it implemented correctly, add the following driver class and text file to your project: ThemeParkApp.java, sample.txt. This driver reads various commands from the text file. Important details about these commands and the driver can be found in the Driver Details & Commands section towards the end of this write-up. Right now jump to that section, reading and understanding it thoroughly before coming back here. Once you’ve done that, only the “Enter” and “Status” commands should work correctly as the others are yet to be implemented.

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

import java.util.NoSuchElementException;

/**
*
* @author Add the following class to your Java project that will be
* used as the linked list nodes of the queue: BGNode.java. Create a new java
* class called RideQueue for the queue. This will be a queue of boarding groups
* and must implement the following interface: QueueADT.java.
*/
public class RideQueue implements QueueADT<BoardingGroup> {

    /**
    * Your RideQueue class should have five private fields with names and data
    * types as follows:
    *
    * • BGNode: front, back
    *
    * • int: capacity, numOfPeople, numOfGroups
    *
    */
    private BGNode front;
    private BGNode back;

    private int capacity, numOfPeople, numOfGroups;

    /**
    * Constructs an empty queue with the designated capacity.
    *
    * @param capacity - The number of people this queue can fit.
    */
    public RideQueue(int capacity) {
       this.front = null;
       this.back = null;
       this.capacity = capacity;
       this.numOfPeople = 0;
       this.numOfGroups = 0;
    }

    /**
    * Determines whether or not this queue is empty.
    *
    * @return True when queue is empty, false otherwise.
    */
    @Override
    public boolean isEmpty() {
       return front...

By purchasing this solution you'll be able to access the following files:
Solution.zip.

$64.00
for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats