QuestionQuestion

Camp Posanivee Description

The director of Camp Posanivee is frustrated. Campers are enrolling and withdrawing from camp faster than her primitive filing system can handle, and she has turned to you. You have been offered free meals at the mess hall in return for a program that will help her keep track of who is enrolled for the two-week summer camp.

Your program will use a binary search tree to maintain the set of campers enrolled in Camp Posanivee. Your program should not be case-sensitive.

Your program will consist of a loop to process commands. The commands should come from a text file (say, "camp.txt"). The program quits when the command 'Q' is given. Below is a list of commands your program should support:

H Help: print a list of commands
E name age gender Enroll a new camper (insert)
W name Withdraw a camper (delete)
D name Display the age and gender of a camper
A Print the average age of the campers
L List all campers names in alphabetical order
S Print the number of boy and girl campers
P List all campers names in preorder
Q Quit

Here name is a string of at most 20 non-blank characters, age is an integer, and gender is either M or F. You may assume command arguments are separated by one or more spaces.

Be sure to echo the input, especially for commands that give no output (like E or W), and handle special cases in a clean way (for example, computing the average age of an empty tree should not crash your program).

Notes

1. Before you begin programming, sketch a high level design of what you want to implement using the UML notation. At the very least, you should have a use case diagram, class diagram and a sequence diagram.
2. Remember to include comments at the top of your program and 1-2 lines for each function (including pre- and post-conditions). Use javadoc compatible comments.

Hand In

Submit, in a single MS Word or PDF document, with the following clearly defined sections:

1. Listing (print-out) of your nicely formatted program source code (with comments and headers)
2. Print-out of the text/data file that contains your camp information
3. Print-out of three sample run outputs (do not simply copy and paste the sample runs, I want to see screen captures of your output screen!)
4. High level design using UML notation (minimum of a use case diagram, a class diagram for Camp class, & a sequence diagram)

Example

Here is a sample input file:

A
E Kanga 26 F E Tigger 28 M E Pooh 31 M
L
D Tigger
E Rabbit 30 M A
S
E Eeyore 36 M W Kanga
P Q

Here is the output that corresponds:
Welcome to Camp Posanivee!! Command: A
There are no campers.

Command: E Kanga 26 F New camper added.

Command: E Tigger 28 M New camper added.

Command: E Pooh 31 M New camper added.

Command: L
Alphabetical List of Campers: Kanga
Pooh Tigger

Command: D Tigger Name: Tigger

Age: 28 Gender: M

Command: E Rabbit 30 M New camper added.

Command: A
Average age = 28.75

Command: S
Camper count by gender: boys = 3
girls = 1

Command: E Eeyore 36 M New camper added.

Command: W Kanga Camper withdrawn.

Command: P
Preorder Traversal:
Pooh Eeyore Tigger Rabbit

Command: Q
End of program.
Bring plenty of calomine lotion!

Solution PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

public class Camper implements Comparable<Camper> {

private String name;
private int age;
private String gender;

public Camper(String name, int age, String gender) {
    this.name = name;
    this.age = age;
    this.gender = gender;
}

public String getName() {
    return name;
}

public void setName(String name) {
    this.name = name;
}

public int getAge() {
    return age;
}

public void setAge(int age) {
    this.age = age;
}

public String getGender() {
    return gender;
}

public void setGender(String gender) {
    this.gender = gender;
}

@Override
public int compareTo(Camper other){
    return name.compareTo(other.getName());
}

public String toString() {
    return name;
}

}...
$70.00 for this solution

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

Find A Tutor

View available Data Structures and Algorithms 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