Question: Hello, I need help with my Java assignment. I think all you need to do is to create instance variables and the constructor on Sailboat.Java

Hello, I need help with my Java assignment. I think all you need to do is to create instance variables and the constructor on Sailboat.Java file, please let me know if there are any other information needed to complete this. Thank you in advance.

Hello, I need help with my Java assignment. I think all youneed to do is to create instance variables and the constructor onSailboat.Java file, please let me know if there are any other informationneeded to complete this. Thank you in advance. Today's 'POD.java' has been

Today's 'POD.java' has been created for you. It makes use of the Sailboat class. It reads in boat names, instantiates the class Sailboat (multiple times), and then prints out the result using the toString() method. You are going to create a Sailboat class in 'Sailboat.java'. You've been given an empty Sailboat class. Inside this empty class, you will create the instance variables, the constructor and write the 'toString() method to be used for output. Details of the Sailboat class Sailboat -counter: int -dockSpace: int -boatName: String +Sailboat (name: String) +toString(): String Input Create the following instance variables: string boatName: the name of the sailboat integer counter: static value to be used within the class to keep track of how many dock spaces have already been used. private static int counter; 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 dockSpace field Complete 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) Sample Output (POD.Java) Yeah, buoy! What's up dock? Yeah, buoy! is at dock space 1 What's up dock? is at dock space 2 New 1 Exit Full Screen POD.Java Sailboat.Java 1. import java.util.Scanner; 3. 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++; 1 Exit Full Screen PopJava Sallboat.javag - New public class Sailboat { 2 /PLEASE START YOUR CODE HERE 3456789gnuBHSBH8982 If // PLEASE END YOUR CODE HERE }

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!