1. Write a fully-documented class namedProductLoadwhich contains the product name (String), it's weight in tons (double), it's value in dollars (double), and whether the product is dangerous or not...



1. Write a fully-documented class namedProductLoadwhich contains the product name (String), it's weight in tons (double), it's value in dollars (double), and whether the product is dangerous or not (boolean). You should provide accessor and mutator methods for each variable. The mutator methods for weight and value should throw exceptions for illegal arguments (i.e. negative values). The class should include a constructor. The full list of required methods is:




  • public ProductLoad- constructor (you may include a constructor with parameters)

  • getter and setter methods for each variable




2. Write a fully-documented class namedTrainCarwhich contains a length in meters (double), a weight in tons (double), and a load reference (ProductLoad). The load variable of the train may benull, which indicates that the train car is empty and contains no product. The train car should have accessor methods for the length, weight, and load variables; however, you should only provide a mutator method for the load variable (the car weight and length should be constant once set). In addition, the class should specify a constructor method (with whatever parameters are necessary), and a method determining whether the car is empty or not. The full list of required methods is:




  • public TrainCar- constructor (you may include a constructor with parameters)

  • getter methods for each variable

  • setter method only for the load variable.



  • isEmpty() method



3. Write a fully-documented class namedTrainCarNodewhich acts as a node wrapper around aTrainCarobject. The class should contain twoTrainCarNodereferences (one for the next node in the chain, one for the previous node in the chain), and oneTrainCarreference variable containing the data. Include mutator/accessor methods for each member variable, and a constructor method. The full list of required methods is:




  • public TrainCarNode- constructor (you may include a constructor with parameters)

  • getter and setter methods for each variable





ProductLoad, TrainCar, and TrainCarNode UML specification.



4. Write a fully-documented class namedTrainlinkedListwhich implements a Double-Linked List ADT. The class should contain references to the head and tail of the list, as well as a cursor variable (allTrainCarNode), and should provide methods to perform insertion, deletion, search, and various other operations. The class will be based on the following ADT specification:



public class TrainLinkedList
TheTrainlinkedListclass implements an abstract data type for a Double-Linked List of train cars supporting some common operations on such lists, as well as a few others.




  • public TrainLinkedList()



    • Brief:

      • Constructs an instance of theTrainLinkedListwith noTrainCarobjects in it.




    • Postconditions:

      • ThisTrainLinkedListhas been initialized to an empty linked list.

      • head, tail, and cursor are all set to null.







  • public TrainCar getCursorData()



    • Brief:

      • Returns a reference to theTrainCarat the node currently referenced by the cursor.







Sep 17, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here