Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

TestBoat.java coding here: import java.util.*; /** * TestBoat ... a class to test the Boat and Motor class hierarchies */ public class TestBoat { //

image text in transcribedimage text in transcribedimage text in transcribed

TestBoat.java coding here:

import java.util.*;

/** * TestBoat ... a class to test the Boat and Motor class hierarchies */

public class TestBoat { // Main program public static void main(String[] args) { // check for two boats worth of info in args if(args.length != 6) { System.out.println("There should be 3 arguments per boat: " + " HullID, Model, Type " + "and there should be 2 boats (= 6 arguments)"); System.exit(1); } // Get boat 1 info String hullid = args[0]; String model = args[1]; String type = args[2]; // Make an Outboard motor, store it as a Motor, and pass to Boat constructor Motor motor1 = new Outboard("Mercury", 2005, 90, "4-stroke"); Boat boat1 = new Boat(hullid, model, type, motor1); System.out.println("boat1: " + boat1 + " "); // Get boat 2 info hullid = args[3]; model = args[4]; type = args[5]; // Make an InboardOutboard motor, store it as a Motor, and pass to Boat constructor Motor motor2 = new InboardOutboard("OMC", 1989, 170, 6); Boat boat2 = new Boat(hullid, model, type, motor2); System.out.println("boat2: " + boat2); } }

In this example, we are going to model boats in a boat dealer's inventory. Here is the UML for this example Boat mfg (String) //manufacturer code) -serialNumber (int) month (nt)//of mfg modelYear (int) modelName (String) type (String) motor (Motor) +Boat(_hullid.-model, Motor make (String) year (int) hp (int) +Motor)//constructor +Motor make,_year, _hp) type, _motor) //constructor +ge tHullD0:String //constructor toString():String +toString):String Outboard InboardOutboard type (String) cylinders (int) +Inboardoutboard( //2-stroke or 4-stroke +Outboard_make, _year, _hp, _type) make,_year, _hp, cylinders) //constructor //constructor +toString):String +toString):String NOTES: Outboard is-a Motor... InboardOutboard is-a Motor... Boat has-a Motor Implement these four classes, plus a test class. The test class will instantiate two boats and two Motors (one for each) and then print out the toString() for each boat. In this example, we are going to model boats in a boat dealer's inventory. Here is the UML for this example Boat mfg (String) //manufacturer code) -serialNumber (int) month (nt)//of mfg modelYear (int) modelName (String) type (String) motor (Motor) +Boat(_hullid.-model, Motor make (String) year (int) hp (int) +Motor)//constructor +Motor make,_year, _hp) type, _motor) //constructor +ge tHullD0:String //constructor toString():String +toString):String Outboard InboardOutboard type (String) cylinders (int) +Inboardoutboard( //2-stroke or 4-stroke +Outboard_make, _year, _hp, _type) make,_year, _hp, cylinders) //constructor //constructor +toString):String +toString):String NOTES: Outboard is-a Motor... InboardOutboard is-a Motor... Boat has-a Motor Implement these four classes, plus a test class. The test class will instantiate two boats and two Motors (one for each) and then print out the toString() for each boat

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David M Kroenke, David J Auer

6th Edition

0132742926, 978-0132742924

More Books

Students also viewed these Databases questions

Question

Define succession planning. Why is it important?

Answered: 1 week ago

Question

u = 5 j , v = 6 i Find the angle between the vectors.

Answered: 1 week ago