Engineering
Engineering, 03.03.2020 00:46, gerardogonzale2294

Each concrete class must have a toString() method defined that prints out its attributes. These objects are not designed to be the most efficient or consistent objects (some throw exceptions for bad arguments, some go to defaults). Instead, I want to see how you handle different input cases. Don't try to over-analyze the problems. Even if I don't specify how to handle bad input, use common sense! You should always handle bad input somehow, do not throw runtime exceptions! Don't assign values to a variable that don't make sense ANYWHERE in your code (example, don't set the number of engines on an aircraft to a negative number!).Make sure that attributes are not publicly accessible!Also, you need to review the Coding Guidelines which explain acceptable ways to format your source code. Please use these in all future homeworks. Step 1:Define an interface ContactThat has the following methods (notice that some are for type String, this means you'll have to convert them to int's)getLength/setLength (int)getSpeed/setSpeed (int)setSpeed(String)getName/setNam e (String)getType/setType (String) (This is an arbitrary string label for anything of class Contact)Step 2: Define an abstract class Ship that implements the Contact Interface. The methods in contact should be defined (no longer abstract, but they can be overriden later on).Step 3: Define a class Destroyer that subclasses Shipthat has the following attributes and get/set methods. Supports int and String setNumberMissiles() arguments. If the String argument of setNumberMissiles() encounters a parsing error, set the numberMissiles to 2.numberMissileStep 4: Define a class Submarine that subclasses Shipthat has the following attributes and get/set methods. Supports int and String setNumberTorpedos() arguments. If the String argument of setNumberTorpedos() encounters a parsing error, set the numberTorpedos to 2numberTorpedosStep 5: Define an abstract class Aircraft that implements the Contact Interface. This class should also contain a getAltitude/setAltitude(int) method. Step 6: Define a class P3 that extends the Aircraft abstract classThat has the following attributes and get/set methods. Not string method is necessary for this one, just handle integers for the accessor (get) and modifier (set) methods. numberEnginesStep 7: In a test class:,Create 2 DestroyersCreate 2 SubmarinesCreate 2 P3sMake a collection of Destroyers (you select the type of Collection)Make a collection of Submarines (you select the type)Make a collection that holds all ShipsMake a collection that holds all ContactsYou get to pick the names and values for the classes above. Step 8: Print out the list of Contacts to System. out. println(). You should override the toString() method to return something "meaningful" for each class. Again, no hard requirements, just use a little common sense (i. e. print out more than the name).

answer
Answers: 1

Other questions on the subject: Engineering

image
Engineering, 04.07.2019 18:10, bckyanne3
Afull journal bearing has a journal diameter of 27 mm, with a unilateral tolerance of -0.028 mm. the bushing bore has a diameter of 27.028 mm and a unilateral tolerance of 0.04 mm. the l/d ratio is 0.5. the load is 1.3 kn and the journal runs at 1200 rev/min. if the average viscosity is 50 mpa-s, find the minimum film thickness, the power loss, and the side flow for the minimum clearance assembly.
Answers: 1
image
Engineering, 04.07.2019 18:10, wyattlb97
Water at the rate of 1 kg/s is forced through a tube with a 2.5 cm inner diameter. the inlet water temperature is 15°c, and the outlet water temperature is 50°c. the tube wall temperature is 14°c higher than the local water temperature all along the length of the tube. what is the length of the tube?
Answers: 3
image
Engineering, 04.07.2019 19:10, ultimateapes
When subject to a steady load (within elastic range) over a long period of time, what is the major difference in material behavoir between steel and plastic?
Answers: 2
image
Engineering, 04.07.2019 19:10, juneham
Estimate the change in specific internal energy au and specific enthalpy h from inlet to outlet for ethylene glycol (a liquid) flowing through each of the following devices: (a) a heat exchanger where the glycol temperature increases from 20 °c to 80 °c; (b) a pump operating at about 25 °c and increasing the glycol pressure from 100 kpa to 8 mpa.
Answers: 2
Do you know the correct answer?
Each concrete class must have a toString() method defined that prints out its attributes. These obje...

Questions in other subjects:

Konu
Mathematics, 14.01.2022 06:50