Question: JAVA Netbeans Assignment 14: Space Craft Objectives Create a Space Craft class. Create classes which build on Space Craft: Space Station and Space Shuttle. Create

JAVA Netbeans

Assignment 14: Space Craft

Objectives

Create a Space Craft class.

Create classes which build on Space Craft: Space Station and Space Shuttle.

Create a toString method for each class.

Store a list of objects in an ArrayList.

Motivation

In this program, you will be creating an application to hold various types of space craft.

Instructions

Name your project FirstnameLastnameAssignmentNumber

The Space Craft Class

A space craft is a generic term for an object in space which holds people. The SpaceCraft class needs to be a public abstract class. People sit in seats. Your SpaceCraft class should have the fields:

String name; // The name of the space craft

int seats; // How many people can sit in this space craft.

Methods

Constructor(String name, int seats): Assigns the parameters to the fields.

getName(): String: Returns the name of the space craft.

getSeats(): int: Returns the number of seats.

Override toString(): String: Returns a string containing the name and number of seats in this generic space craft.

The Space Station Class

A space station doesn't move in space. It houses people. The SpaceStation class needs to extend SpaceCraft. It should have the following fields:

int ports; // Number of ports on this space station.

Methods

Constructor(String name, int seats, int ports): Assigns the parameters to the fields.

getPorts(): int: Returns the number of ports.

Override toString(): String: Returns the name and number of ports on this space station.

The Space Shuttle Class

A space shuttle moves people around in space. A space shuttle has engines. The SpaceShuttle class needs to extend SpaceCraft. It should have the following fields:

int engines; // Number of engines on this space station

Methods

Constructor(String name, int seats, int engines): Assigns the parameters to the fields.

getEngines(): int: Returns the number of engines.

Override toString(): String: Returns the name and number of engines on this space shuttle.

Main Method

Your main method should begin with an empty ArrayList of SpaceCraft objects.

Write a menu based application which does the following:

Adds a new station to the list. You will need to prompt for three parts of a station.

Adds a new shuttle to the list. You will need to prompt for three parts of a shuttle.

Display the number of space craft in the list.

Display the number total number of seats in all space craft in the list.

Display a description of all space craft.

Quit the software.

Notes

The only class which is allowed to have print statements is the class with your main method. If any methods have a print statement outside this class, you will get an automatic 0. I'm writing this because it is a bad programming practice to put print statements in methods outside of main.

Example Run

In this example run, I add Deep Space Station K-12 and the Enterprise to my space craft organizer. Your organizer should behave like this for full credit.

Welcome to Jamies Space Craft Organizer. 1. Add a new space station. 2. Add a new space shuttle. 3. Display count of all space craft. 4. Display count of number of seats. 5. Display description of all space craft. 6. Quit. Enter an option from 1 to 6: 1 Enter a new Space Station. Enter the name: K-12 Enter the number of seats: 1000 Enter the number of ports: 100 1. Add a new space station. 2. Add a new space shuttle. 3. Display count of all space craft. 4. Display count of number of seats. 5. Display description of all space craft. 6. Quit. Enter an option from 1 to 6: 2 Enter a new Space Shuttle. Enter the name: Enterprise Enter the number of seats: 500 Enter the number of engines: 2 1. Add a new space station. 2. Add a new space shuttle. 3. Display count of all space craft. 4. Display count of number of seats. 5. Display description of all space craft. 6. Quit. Enter an option from 1 to 6: 3 There are 2 space craft. 1. Add a new space station. 2. Add a new space shuttle. 3. Display count of all space craft. 4. Display count of number of seats. 5. Display description of all space craft. 6. Quit. Enter an option from 1 to 6: 4 There are 1500 seats across all space craft. 1. Add a new space station. 2. Add a new space shuttle. 3. Display count of all space craft. 4. Display count of number of seats. 5. Display description of all space craft. 6. Quit. Enter an option from 1 to 6: 5 All Space Craft. Space Station K-12 has 100 ports. Space Shuttle Enterprise has 2 engines. 1. Add a new space station. 2. Add a new space shuttle. 3. Display count of all space craft. 4. Display count of number of seats. 5. Display description of all space craft. 6. Quit. Enter an option from 1 to 6: 6

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!