Step 1 Create Manufacturedproduct Class Manufacturedproduct Class Simplified Representatio Q43800668
Step 1
Create a ManufacturedProduct class. The ManufacturedProductclass is a simplified representation of a product that is beingbuilt on an assembly line.
The data in a ManufacturedProduct object are as follows:
- A private integer instance variable called productId.
- A private boolean instance variable calledpassedInspection.
The ManufacturedProduct class should have the followingadditional members:
- A constructor that sets the productId value. Allow theinspection variable to have a default value of your choice.
- A get method for the productId value. No set method should beprovided. The only way to assign the productId is with theconstructor.
- A toString() method that returns a String that is a report onthe data in a ManufacturedProduct object.
ALSO…
Remember that the AssemblyLine array (see below) represents anactual assembly line. After a ManufacturedProduct object is finallyreturned by the insert method, it should be inspected to see if ithas been correctly assembled.
So also give the ManufacturedProduct class a public inspectionmethod. All it should do is generate a random number in the rangezero to nineteen. If a zero is generated, set the passedInspectionvariable to false. Otherwise, set it to true.
Step 2
Create an AssemblyLine class. An assembly line is, of course, agood real-world representation of a queue.
The AssemblyLine class has an encapsulated ManufacturedProductarray with five elements. Each element represents a position on anactual assembly line.
Give the AssemblyLine class a public insert method that adds aManufacturedProduct object to element zero the ManufacturedProductarray. If any objects are already in the array, shift all of themone element ‘up’ the ManufacturedProduct array.
Example:
- We are adding a ManufacturedProduct object to the array.However, we already have an object in the array. The new objectoccupies element zero in the array and the old object shifts up toelement one.
- Then we insert another object. The new object goes into elementzero. The object we inserted previously shifts up to element one.And the first object now occupies element two.
- etc.
The insert method should also return a ManufacturedProductobject. However, it will only return the ManufacturedProduct objectthat is currently the object in element four of theManufacturedProduct array. Otherwise, it will return a null.
Example:
- We have five objects in the five element ManufacturedProductarray. When a sixth object is added, it goes to element zero andall of the objects in the array shift up one in the element count– except for the object in element number four, which is actuallyreturned by the insert method.
The only way to add or return an element from the array shouldbe via the insert method.
Remember that you should inspect each ManufacturedProduct objectwhen they are finally returned by the insert method.
Step 3
Create an AssemblyLineTest class — it should contain your mainmethod.
In the main method, instantiate an AssemblyLine object. Use yourinsert() method to add twenty ManufacturedProduct objects into theAssemblyLine object. Go ahead and hard code the ManufacturedProductobjects — you don’t need to use a Scanner to get user input.
As the insert method returns ManufacturedProduct objects, display areport on each object.
Expert Answer
Answer to Step 1 Create a ManufacturedProduct class. The ManufacturedProduct class is a simplified representation of a product tha…
OR