Question: 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[]
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"); } }
![import java.util.Scanner; public class PoD { public static void main( String []](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f5238bbe500_45166f5238b4e265.jpg)
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 SdockSpaces 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? Sample output (POD.Java) Yeah, buoy! is at dock space 1 What's up dock? is at dock space 2 END OF OUTPUT
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
