Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Java In this assignment, you will write a train car manager for a commerical train. The train, modelled using a Double-Linked List data structure, consists
Java
In this assignment, you will write a train car manager for a commerical train. The train, modelled using a Double-Linked List data structure, consists of a chain of train cars, each of which contains a product load. A product load has a weight, a value, and can be dangerous or safe. The train car manager will be able to add and remove cars from the train, set the product load for each car, and determine useful properties of the train, such as it's length, weight, total value, and whether it contains any dangerous product loads. 1. Write a fully-documented class named ProductLoad which 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 (ie. 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 named TrainCar which contains a length in meters (double), a weight in tons (double), and a load reference (ProductLoad). The load variable of the train may be null, 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 ful 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. isEmpty0 method 3. Write a fully-documented class named TrainCarNode which acts as a node wrapper around a TrainCar object. The class should contain two TrainCarNode references (one for the next node in the chain, one for the previous node in the chain), and one TrainCar reference variable containing the data. Iaclude 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 TrainCarNode TrainCar ProductLoad prev TrainCarNode next: TrainCarNode car TrainCar carLength : double carWeight: double load: ProductLoad name: String weight: double value :ubio isDangerous: boolearn constructors constructors: TrainCan carWeight: double, TrainCarNode) TrainCarNode(car: TrainCar) carLength: double) Productl.oadname: String weight: double, value: double, getters /setters getters/ setters: All member vaniables getCarWeight0 : double isDangerous:boolean) getcarLength) : dobule setProductLoad(load: ProductLoad) : void methods methods: toString): String getterssetters W member variables. isEmptyo: boolean ProductLoad, TrainCar, and TrainCarNode UML. specificationStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started