subject

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

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 04:30
Eye injuries usually occur as a result of all of the following things, except: a) proper machine operation b) battery explosion c) falling or flying debris d) electric welding arc
Answers: 2
question
Computers and Technology, 22.06.2019 20:40
Write a program that begins by reading in a series of positive integers on a single line of input and then computes and prints the product of those integers. integers are accepted and multiplied until the user enters an integer less than 1. this final number is not part of the product. then, the program prints the product. if the first entered number is negative or 0, the program must print “bad input.” and terminate immediately. next, the program determines and prints the prime factorization of the product, listing the factors in increasing order. if a prime number is not a factor of the product, then it
Answers: 2
question
Computers and Technology, 22.06.2019 23:50
You need to design a circuit that implements the functions in the following table: s0 s1 function0 0 a + 10 1 a – b1 0 a + b1 1 a – 1s0 and s1 are 1-bit control inputs to select the function of the circuit. inputs a and b are 4-bitnumbers in 2s complement form. the output is also a 4-bit number in 2s complement form.you are allowed to use only one ttl 7483 4-bit adder to implement all the functions. but anynumber of other components (except the adder) can be used.hint: design a combinational logic circuit to modify the input b and the “carry input” of theadder depending on the control inputs s0 and s1.important: lab grade will depend on the working of the circuit & will be checked of by your labinstructor.1. is the output valid for the following input combinations: a. s0 = 0, s1 = 0, a = 7, b = 3? b. s0 = 0, s1 = 1, a = 7, b = 3? c. s0 = 1, s1 = 0, a = -4, b = -5? d. s0 = 1, s1 = 1, a = -8, b = 6? 2. what is the range of inputs (for both a and b) that will produce the valid output for all the functions?
Answers: 3
question
Computers and Technology, 23.06.2019 04:00
Write a method that takes in an array of point2d objects, and then analyzes the dataset to find points that are close together. be sure to review the point2d api. in your method, if the distance between any pair of points is less than 10, display the distance and the (x,y)s of each point. for example, "the distance between (3,5) and (8,9) is 6.40312." the complete api for the point2d adt may be viewed at ~pf/sedgewick-wayne/algs4/documentation/point2d.html (links to an external site.)links to an external site.. try to write your program directly from the api - do not review the adt's source code.
Answers: 1
You know the right answer?
Each concrete class must have a toString() method defines that prints out its attributes. These obje...
Questions
Questions on the website: 13722363