Computers and Technology
Computers and Technology, 28.02.2020 00:52, tonio638

Each concrete class must have a toString() method defines that prints out its attributes. These objects are not desgined 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 Contact
That 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/setName (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 Ship
that 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.
numberMissile
Step 4: Define a class Submarine that subclasses Ship
that 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 2
numberTorpedos
Step 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 class
That 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.
numberEngines
Step 7: In a test class:,
Create 2 Destroyers
Create 2 Submarines
Create 2 P3s
Make 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 Ships
Make a collection that holds all Contacts
You 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

answer
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 10:40, pbarbee3034
Nims is applicable to all stakeholders with incident related responsibilities. true or false
Answers: 1
image
Computers and Technology, 23.06.2019 12:00, clevelandjaniya1
Which of these is a benefit of using objects in a powerpoint presentation? a. collaborators can create the external files while you create and edit the slide show. b. you can easily change the theme and design of the presentation. c. you can have older data in the source file while having up-to-date data in the presentation. d. collaborators can easily share the presentation.
Answers: 2
image
Computers and Technology, 23.06.2019 14:30, rose6038
Select the correct answer. peter has launched a website that features baby products. however, clients often find they are unable to access the website because the server is down. which feature of cybersecurity should peter focus on for his website? a. data authenticity b. data privacy c. data availability d. data integrity e. data encryption
Answers: 3
image
Computers and Technology, 24.06.2019 00:00, marika35
Visualizing a game of β€œtag” to remember the meaning of contagious
Answers: 3
Do you know the correct answer?
Each concrete class must have a toString() method defines that prints out its attributes. These obje...

Questions in other subjects: