Create a class called Carrier that has the following attributes: Carrier() Carrier(numberOfSpaceFighter Docks, numberOfDrill Docks, cargoholdSize) Carrier spaceFighterDocks[] SpaceFighter drillDocks[] - Drill cargohold[] - String deployFighter() SpaceFighter dockFighter(SpaceFighter) - Boolean deployDrill() Drill dockDrill(Drill) - Boolean addItemToCargohold(String) - Boolean removeltemFromCargohold(String) - Boolean toString() - String Note: The deploy and dock method just add or remove things from the corresponding arrays of SpaceFighter and Drill. When you dock something, if the array full, return false; otherwise true. Similarly for the Cargo methods.

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter10: Introduction To Inheritance
Section: Chapter Questions
Problem 1GZ
icon
Related questions
Question

26

### Class: Carrier

The `Carrier` class in this educational module encompasses several attributes and methods related to maintaining and manipulating space fighters, drills, and a cargo hold.

#### Attributes:
1. **spaceFighterDocks[]**: `SpaceFighter`
2. **drillDocks[]**: `Drill`
3. **cargohold[]**: `String`

#### Constructors:
- **Carrier()**: Default constructor.
- **Carrier(numberOfSpaceFighterDocks, numberOfDrillDocks, cargoholdSize)**: Parameterized constructor to initialize the Carrier with specified sizes for the docks and cargo hold.

#### Methods:
1. **deployFighter()**: `SpaceFighter`
    - Deploys a space fighter from the carrier.

2. **dockFighter(SpaceFighter)**: `Boolean`
    - Docks a space fighter into the carrier. Returns `true` if successful, `false` if the dock is full.

3. **deployDrill()**: `Drill`
    - Deploys a drill from the carrier.

4. **dockDrill(Drill)**: `Boolean`
    - Docks a drill into the carrier. Returns `true` if successful, `false` if the dock is full.

5. **addItemToCargohold(String)**: `Boolean`
    - Adds an item to the cargohold. Returns `true` if successful, `false` if the cargo hold is full.

6. **removeItemFromCargohold(String)**: `Boolean`
    - Removes an item from the cargohold. Returns `true` if successful, `false` if the item does not exist.

7. **toString()**: `String`
    - Converts the carrier's current state to a string representation.

#### Note:
- The `deploy` and `dock` methods manage the respective arrays for `SpaceFighter` and `Drill`. When docking, if the respective array is full, the method returns `false`; otherwise, it returns `true`. Similarly, this logic is applied to adding and removing items from the cargo hold.

#### Explanation:
The depiction in the image includes fields and methods within a tabular structure that delineates the components of the `Carrier` class. The constructors and methods offer a comprehensive way to handle docking and deploying space assets and managing cargo in the system.
Transcribed Image Text:### Class: Carrier The `Carrier` class in this educational module encompasses several attributes and methods related to maintaining and manipulating space fighters, drills, and a cargo hold. #### Attributes: 1. **spaceFighterDocks[]**: `SpaceFighter` 2. **drillDocks[]**: `Drill` 3. **cargohold[]**: `String` #### Constructors: - **Carrier()**: Default constructor. - **Carrier(numberOfSpaceFighterDocks, numberOfDrillDocks, cargoholdSize)**: Parameterized constructor to initialize the Carrier with specified sizes for the docks and cargo hold. #### Methods: 1. **deployFighter()**: `SpaceFighter` - Deploys a space fighter from the carrier. 2. **dockFighter(SpaceFighter)**: `Boolean` - Docks a space fighter into the carrier. Returns `true` if successful, `false` if the dock is full. 3. **deployDrill()**: `Drill` - Deploys a drill from the carrier. 4. **dockDrill(Drill)**: `Boolean` - Docks a drill into the carrier. Returns `true` if successful, `false` if the dock is full. 5. **addItemToCargohold(String)**: `Boolean` - Adds an item to the cargohold. Returns `true` if successful, `false` if the cargo hold is full. 6. **removeItemFromCargohold(String)**: `Boolean` - Removes an item from the cargohold. Returns `true` if successful, `false` if the item does not exist. 7. **toString()**: `String` - Converts the carrier's current state to a string representation. #### Note: - The `deploy` and `dock` methods manage the respective arrays for `SpaceFighter` and `Drill`. When docking, if the respective array is full, the method returns `false`; otherwise, it returns `true`. Similarly, this logic is applied to adding and removing items from the cargo hold. #### Explanation: The depiction in the image includes fields and methods within a tabular structure that delineates the components of the `Carrier` class. The constructors and methods offer a comprehensive way to handle docking and deploying space assets and managing cargo in the system.
Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Software Development
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,