Instructions If you think my puns are bad, you should check out boat names as you walk past any dock! Today, you are going to be working with some boat names that are docked at a local marina. Today's POD.java has been created for you. You are going to create a Sailboat class in Sailboat.java. POD.java makes use of the Sailboat class. You are going to write the Sailboat class in Sailboatjava You've been given an empty Sallboat class. Inside this empty class, you will create the fields, the constructor and write the toString() method to be used for output. The main method in POD.java has been written for you. It reads in boat names, instantiates the class Sailboat (multiple times), and then prints out the result using the toString() method. Details Input Create the following class fields: - string boatName: the name of the sailboat - counter counter: static value to be used within the class to keep track of how many dock spaces have already been used so far. - integer dockSpace: number of the dock space the sailboat will be assigned. When a new sailboat is brought into the marina (i.e. constructed), it will be assigned a dock space one greater than the one before it. Processing Create a Sailboat constructor: - The following input parameter is expected: - string: the name of the boat to be docked - Assign this boat name to the appropriate field - Increment the counter · Assign the new counter to the ȘdockSpaces field Create the toString() method for output (as below) Output The output is achieved by using the toString() method in the Sallboat.Java object class. It should be of the format BOAT-NAME is at dock space DOCK-SPACE Sample Input/output: Sample input (PoD.Java) Yeah, buoy! What's up dock?

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Java.

Starter Code for PoD class:

import java.util.Scanner;

public class PoD {

public static void main( String [] args ) {


Scanner in = new Scanner(System.in);

final int MARINA_SIZE= 10;

String[] boatNames = new String[MARINA_SIZE];
Sailboat[] boats = new Sailboat[MARINA_SIZE];

int i = 0;

while (in.hasNextLine())
{
boatNames[i] = in.nextLine();
boats[i] = new Sailboat(boatNames[i]);
System.out.println(boats[i]);
i++;
}

System.out.print("END OF OUTPUT");
}
}

 

Other code for class Sailboat:

public class Sailboat
{

// PLEASE START YOUR CODE HERE
// *********************************************************











// *********************************************************
// PLEASE END YOUR CODE HERE

}

### Test Case Analysis

#### Input of the Test Case
```plaintext
1. Yeah, Buoy!
2. Unsinkable 2
3. Vitamin Sea
```

#### Your Code's Output
```plaintext
1. Error: Could not find or load main class PoD
2. Caused by: java.lang.ClassNotFoundException: PoD
```

#### The Correct Output of the Test Case
```plaintext
1. Yeah, Buoy! is at dock space 1
2. Unsinkable 2 is at dock space 2
3. Vitamin Sea is at dock space 3
4. END OF OUTPUT
```

### Explanation

- **Test Case Input:** This section contains three lines, each specifying the name of a boat:
  1. "Yeah, Buoy!"
  2. "Unsinkable 2"
  3. "Vitamin Sea"

- **Your Code's Output:** This section shows an error message encountered during execution:
  1. "Error: Could not find or load main class PoD" – indicates that the main class `PoD` could not be found or loaded.
  2. "Caused by: java.lang.ClassNotFoundException: PoD" – the specific exception that caused the error, highlighting that the class `PoD` is not found.

- **The Correct Output of the Test Case:** This section displays the expected output, which lists each boat's name followed by its designated dock space:
  1. "Yeah, Buoy! is at dock space 1"
  2. "Unsinkable 2 is at dock space 2"
  3. "Vitamin Sea is at dock space 3"
  4. "END OF OUTPUT" – marks the end of the output.

### Graphs or Diagrams
There are no graphs or diagrams in this image. This exercise is focused on understanding the discrepancy between the actual and expected outputs in a coding context, specifically addressing a class loading issue in the error message.

By correcting the issue pointed out in the error message (ensuring the `PoD` class is properly defined and accessible), the program should produce the correct output as listed above.
Transcribed Image Text:### Test Case Analysis #### Input of the Test Case ```plaintext 1. Yeah, Buoy! 2. Unsinkable 2 3. Vitamin Sea ``` #### Your Code's Output ```plaintext 1. Error: Could not find or load main class PoD 2. Caused by: java.lang.ClassNotFoundException: PoD ``` #### The Correct Output of the Test Case ```plaintext 1. Yeah, Buoy! is at dock space 1 2. Unsinkable 2 is at dock space 2 3. Vitamin Sea is at dock space 3 4. END OF OUTPUT ``` ### Explanation - **Test Case Input:** This section contains three lines, each specifying the name of a boat: 1. "Yeah, Buoy!" 2. "Unsinkable 2" 3. "Vitamin Sea" - **Your Code's Output:** This section shows an error message encountered during execution: 1. "Error: Could not find or load main class PoD" – indicates that the main class `PoD` could not be found or loaded. 2. "Caused by: java.lang.ClassNotFoundException: PoD" – the specific exception that caused the error, highlighting that the class `PoD` is not found. - **The Correct Output of the Test Case:** This section displays the expected output, which lists each boat's name followed by its designated dock space: 1. "Yeah, Buoy! is at dock space 1" 2. "Unsinkable 2 is at dock space 2" 3. "Vitamin Sea is at dock space 3" 4. "END OF OUTPUT" – marks the end of the output. ### Graphs or Diagrams There are no graphs or diagrams in this image. This exercise is focused on understanding the discrepancy between the actual and expected outputs in a coding context, specifically addressing a class loading issue in the error message. By correcting the issue pointed out in the error message (ensuring the `PoD` class is properly defined and accessible), the program should produce the correct output as listed above.
### Instructions

If you think my puns are bad, you should check out boat names as you walk past any dock! Today, you are going to be working with some boat names that are docked at a local marina.

Today's `PoD.java` has been created for you. You are going to create a Sailboat class in `Sailboat.java`.

`PoD.java` makes use of the Sailboat class. You are going to write the Sailboat class in `Sailboat.java`.

You've been given an empty Sailboat class. Inside this empty class, you will create the fields, the constructor and write the `toString()` method to be used for output.

The main method in `PoD.java` has been written for you. It reads in boat names, instantiates the class Sailboat (multiple times), and then prints out the result using the `toString()` method.

### Details

#### Input

Create the following class fields:
- `String boatName`: the name of the sailboat
- `static int counter`: static value to be used within the class to keep track of how many dock spaces have already been used so far.
- `int dockSpace`: number of the dock space the sailboat will be assigned. When a new sailboat is brought into the marina (i.e., constructed), it will be assigned a dock space one greater than the one before it.

#### Processing

Create a Sailboat constructor:
- The following input parameter is expected:
  - `String`: the name of the boat to be docked
- Assign this boat name to the appropriate field
- Increment the counter
- Assign the new counter to the `dockSpace` field

Create the `toString()` method for output (as below)

#### Output

The output is achieved by using the `toString()` method in the `Sailboat.java` object class. It should be of the format:

**BOAT-NAME is at dock space DOCK-SPACE**

#### Sample Input/Output:

**Sample input [PoD.java]**

```
Yeah, buoy!
What's up dock?
```

**Sample output**

```
Yeah, buoy! is at dock space 1
What's up dock? is at dock space 2
```

### Example Code Structure for Sailboat.java

```java
public class Sailboat {
    private String boatName;
    private static int counter = 0;
    private int dock
Transcribed Image Text:### Instructions If you think my puns are bad, you should check out boat names as you walk past any dock! Today, you are going to be working with some boat names that are docked at a local marina. Today's `PoD.java` has been created for you. You are going to create a Sailboat class in `Sailboat.java`. `PoD.java` makes use of the Sailboat class. You are going to write the Sailboat class in `Sailboat.java`. You've been given an empty Sailboat class. Inside this empty class, you will create the fields, the constructor and write the `toString()` method to be used for output. The main method in `PoD.java` has been written for you. It reads in boat names, instantiates the class Sailboat (multiple times), and then prints out the result using the `toString()` method. ### Details #### Input Create the following class fields: - `String boatName`: the name of the sailboat - `static int counter`: static value to be used within the class to keep track of how many dock spaces have already been used so far. - `int dockSpace`: number of the dock space the sailboat will be assigned. When a new sailboat is brought into the marina (i.e., constructed), it will be assigned a dock space one greater than the one before it. #### Processing Create a Sailboat constructor: - The following input parameter is expected: - `String`: the name of the boat to be docked - Assign this boat name to the appropriate field - Increment the counter - Assign the new counter to the `dockSpace` field Create the `toString()` method for output (as below) #### Output The output is achieved by using the `toString()` method in the `Sailboat.java` object class. It should be of the format: **BOAT-NAME is at dock space DOCK-SPACE** #### Sample Input/Output: **Sample input [PoD.java]** ``` Yeah, buoy! What's up dock? ``` **Sample output** ``` Yeah, buoy! is at dock space 1 What's up dock? is at dock space 2 ``` ### Example Code Structure for Sailboat.java ```java public class Sailboat { private String boatName; private static int counter = 0; private int dock
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Random Class and its operations
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
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education