Ship, CruiseShip, and CargoShip Classes Design a Ship class that the following members: A field for...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Ship, CruiseShip, and CargoShip Classes Design a Ship class that the following members: A field for the name of the ship (a string). • A field for the year that the ship was built (a string). • A constructor and appropriate accessors and mutators. • A toString method that displays the ship's name and the year it was built. Design a CruiseShip class that extends the Ship class. The CruiseShip class should have the following members: • A field for the maximum number of passengers (an int). • A constructor and appropriate accessors and mutators. A toString method that overrides the toString method in the base class. The CruiseShip class's toString method should display only the ship's name and the maximum number of passengers. Design a CargoShip class that extends the Ship class. The CargoShip class should have the following members: • A field for the cargo capacity in tonnage (an int). • A constructor and appropriate accessors and mutators. A toString method that overrides the toString method in the base class. The CargoShip class's toString method should display only the ship's name and the ship's cargo capacity. Demonstrate the classes in a program that has a Ship array. Assign various Ship, CruiseShip, and CargoShip objects to the array elements. The program should then step through the array, calling each object's toString method. (See Code Listing 10-25 as an example.) Ship, CruiseShip, and CargoShip Classes Design a Ship class that the following members: A field for the name of the ship (a string). • A field for the year that the ship was built (a string). • A constructor and appropriate accessors and mutators. • A toString method that displays the ship's name and the year it was built. Design a CruiseShip class that extends the Ship class. The CruiseShip class should have the following members: • A field for the maximum number of passengers (an int). • A constructor and appropriate accessors and mutators. A toString method that overrides the toString method in the base class. The CruiseShip class's toString method should display only the ship's name and the maximum number of passengers. Design a CargoShip class that extends the Ship class. The CargoShip class should have the following members: • A field for the cargo capacity in tonnage (an int). • A constructor and appropriate accessors and mutators. A toString method that overrides the toString method in the base class. The CargoShip class's toString method should display only the ship's name and the ship's cargo capacity. Demonstrate the classes in a program that has a Ship array. Assign various Ship, CruiseShip, and CargoShip objects to the array elements. The program should then step through the array, calling each object's toString method. (See Code Listing 10-25 as an example.)
Expert Answer:
Related Book For
Introduction to Java Programming, Comprehensive Version
ISBN: 978-0133761313
10th Edition
Authors: Y. Daniel Liang
Posted Date:
Students also viewed these programming questions
-
Managing Scope Changes Case Study Scope changes on a project can occur regardless of how well the project is planned or executed. Scope changes can be the result of something that was omitted during...
-
This assignment reviews object-oriented programming concepts such as classes, methods, constructors, accessor methods, and access modifiers. It makes use of an array of objects as a class data...
-
Playing cards are used in many computer games, including versions of such classics as solitaire, hearts, and poker. Design a Card class that contains a character data field to hold a suit (s for...
-
The control features of a bank account do not include: (a) having bank auditors verify the correctness of the bank balance per books. (b) minimizing the amount of cash that must be kept on hand. (c)...
-
Air at a static temperature of 70?F and a static pressure of 0.1 psia flows at zero angle of attack over a thin electrically heated flat plate at a velocity of 200 fps. If the plate is 4 in long in...
-
1. What might explain dealers failure to promote the Civic GX, beyond fueling issues? 2. How might Scholfield Honda expand on the changes put into motion by Lindquest? 3. How could the Honda...
-
The Anchor Glass Container Corporation and its parent company, Consumers Packaging, Inc. (CPI), entered into a series of agreements with Encore Glass, Inc., to supply glass containers of a specific...
-
Prepare journal entries in the General Fund of the Brownville School District. a. The District had outstanding encumbrances of $13,000 for band instruments from the previous year. It is the Districts...
-
- Consider an asymmetric Cournot duopoly game, where the two firms have different costs of production. Firm 1 selects quantity 91 at a pro- duction cost of 2q. Firm 2 selects quantity 92 and pays the...
-
Crystal Corporation processes its journal vouchers using batch procedures similar to the process outlined in Figure in the text. To improve customer satisfaction, the sales system is going to be...
-
T is the region of the plane x + y + z = 1 with x, y, z >0. S is the set of points (a, b, c) in T such that just 1 two of the following three inequalities hold: a b -cs 1 cs 1/1 2 54. Area of the...
-
How might the application of cognitive appraisal theory inform motivational interventions aimed at reframing individuals' perceptions of obstacles and setbacks as opportunities for growth and...
-
An investor purchased a corporate bond for $ 9 1 5 . The bond pays 3 . 7 5 % interest and matures this year. Calculate the current yield on the bond investment at the time of purchase. Determine the...
-
A family buys a house for $ 3 3 0 , 0 0 0 . They pay 1 5 % down and the rest is amortized with a 3 0 - year mortgage at 6 . 5 % annual interest, compounded monthly. ( a ) What is the nominal amount...
-
A 5-year bond that pays interest semiannually has a 7% coupon and an 8% quoted yield to maturity. Annual interest rates increase 50 basis points. What is the predicted change in the bond price after...
-
Donald is the owner of a small restaurant, and is considering renovating his kitchen and buying new equipment to keep up with increasing business. He has received a quote of $20,000 from the...
-
Graph the function f(x) = -x + 6x by starting with the graph of y= x and using transformations (shifting, stretching/compressing, and/or reflecting). Use the graphing tool to graph the function....
-
Give the products of the following reaction, where T is tritium: dioldehydrase Ad- CH CH3C-COH CoIII) coenzyme B12
-
Write a program that simulates car racing, as shown inFigure 15.34a. The car moves from left to right. When it hits the right end, it restarts from the left and continues the same process. You can...
-
Listing 3.3, SubtractionQuiz.java, randomly generates a subtraction question. Revise the program to randomly generate an addition question with two integers less than 100. Listing 3.3 1 import...
-
Write a program that finds five prime numbers larger than Long.MAX_VALUE.
-
Which of the following best describes the underlying rationale for a written investment policy statement (IPS)? A. A written IPS communicates a plan for trying to achieve investment success. B. A...
-
Which of the following is least important as a reason for a written investment policy statement (IPS)? A. The IPS may be required by regulation. B. Having a written IPS is part of best practice for a...
-
Which of the following is least likely to be placed in the appendices to an investment policy statement (IPS)? A. Rebalancing Policy. B. Strategic Asset Allocation. C. Statement of Duties and...
Study smarter with the SolutionInn App