Question: second You will write two separate classes. A Captain class that will allow us to create captains for boats and a CaptainTester class (partially complete)

second

You will write two separate classes. A Captain class that will allow us to create captains for boats and a CaptainTester class (partially complete) that we will use to test some of our Captain class methods. The Captain class will also be unit tested. The Captain class diagram is below; you cannot create more public methods than the ones on the diagram. Captain - age: int -name: String - yearsOfExperience: int - registryNumber: int + Captain(int, String, int, int) + getName(): String + getYearsOfExperience(): int + equals(Captain): boolean + toString: String Captain(int, String,int,int): Creates a new captain given an age, name, years of experience and registry number on that order. equals(Captain): This is the simplified version of equals (we are received a Captain object). Two captains are the same if they have the same name and the same registry number. toString(): returns a String according to the example below (Captain's name is Christian Williams): Christian Williams, age: 77 YOE: 50 Registry: 8974 m Captain.java Captain Tester.java New Full Screen 3 Create a captain object using the variables and print ito 4 */ 5 6- import java.util.Scanner; 7 8- public class CaptainTester { 9- public static void main(String[] args) { 10 Scanner kb new Scanner(System.in); 11 String name kb.nextLine(); 12 kb.nextInt(); 13 int yearsOfExperience kb.nextInt(); 14 int registry kb.nextInt(); 15 16 //Create the captain Object here 17 18 19 //Print the captain object here using toString 20 int age == Now you will create a sailboat class. Mimir will insert a solution for the Captain class (you won't be able to see it) in this problem. A sailboat has a size in feet, a name, a model, and a Captain. New sailboats don't have a captain when they are created. Captains are assigned after they are created. How can you use the null reference to tell if there is or there isn't a captain assigned to a sailboat object? Sailboat - size: int - name: String - model: String - Captain: captain + Sailboat(int, String, String) + assignCaptain(Captain): boolean + getCaptain(): Captain + equals(Sailboat): boolean + toString(): String . . ailboat(int, String,String): Creates a new sailboat given size (in feet), name, and model. assignCaptain(Captain): assign a captain to a sailboat. If the sailboat already has a captain, the new captain must have more experience (in years of experience). If the new captain is not more experience the method should return false. equals(Sailaboat): two sailboats are the same if they have the same name and the same captain toString(): returns a String according to the example below: No Captain Assigned Relativity is a 25 feet C&C sailboat with no captain =/ Captain Assigned Relativity is a 25 feet C&C sailboat; her captain is: Albert Einstein
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
