Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

wend Problem 2 (25 points) Henry Ford, the brilliant inventor and industrialist,

ID: 3860448 • Letter: W

Question



wend Problem 2 (25 points) Henry Ford, the brilliant inventor and industrialist, has hired You to design the assembly lne for his new car, the model-ul. The model-U has four assembles: the engine, the steering mechanism, the electrical system and the chassis. Each assembly consists of two Each part has a name and the state of being parts. assembled (true) or disassembled (falsel The parts of each assembly are as folows: values li Part spark li Part) Plugs SteeringMechanismc wheels Part ade 1 Part) The assembly ine works as folows: Eath asseml is assembled by changing the state ofeach of bly Perts to true priming message includna the part name and "s assembled. After complete, quality oontrol tests the rssemi and returns false if the state of its parts disassembled bly Parts String) assembleAndQuality a Assembly boolearl r serState(b boolean) void assemblyLine0 woid gerstate0 bookean

Explanation / Answer

//Assembly.java

public interface Assembly {
   public void assemble();
   public boolean qualityControl();
}

//Part.java

public class Part {

   String name;
   boolean state;
  
  
   public Part(String s){ // Getting Part name
       this.name=s;
   }

// Getting state of part
   public boolean getState() {
       return state;
   }


   public void setState(boolean state) {
       this.state = state;
   }
  
  
}

//ElectricalAssembly.java

public class ElectricalAssembly implements Assembly{

   Part starter,distributer;
  
   public ElectricalAssembly(){
       System.out.println("Electrical Assembly Line");
   }
  

// Overriding the methods of Interface Assembly
   @Override
   public void assemble() {
       starter = new Part("Audio Device");
       System.out.println("The Starter is:"+starter.name);
       starter.setState(true); // Setting the state of quality
   }

   @Override
   public boolean qualityControl() {
       boolean b = starter.getState(); // Getting the state of quality
       return b;
   }
  

}

//EngineAssembly.java

public class EngineAssembly implements Assembly{

   Part valves,sparkPlugs;
  
   public EngineAssembly(){
       System.out.println("Engine Assembly Line");
   }
  
   @Override
   public void assemble() {
       valves = new Part("Globe Valve");
       System.out.println("The valve is:"+valves.name);
       valves.setState(false);
   }

   @Override
   public boolean qualityControl() {
       boolean b = valves.getState();
       return b;
   }
  
  
}

//SteeringAssembly.java

public class SteeringAssembly implements Assembly{

   Part wheel,axle;
  
   public SteeringAssembly(){
       System.out.println("Steering Assembly Line");
   }
  
   @Override
   public void assemble() {
       wheel = new Part(" Closed End Axle Nut");
       System.out.println("The Wheel is:"+wheel.name);
       wheel.setState(false);
   }

   @Override
   public boolean qualityControl() {
       boolean b = wheel.getState();
       return b;
   }
  
  
}

//ChasisAssembly.java

public class ChasisAssembly implements Assembly{

   Part frame,cab;
  
   public ChasisAssembly(){
       System.out.println("Chasis Assembly Line");
   }
  
   @Override
   public void assemble() {
       frame = new Part("Monocoque Chassis");
       System.out.println("The Chasis Frame is:"+frame.name);
       frame.setState(true);
      
   }

   @Override
   public boolean qualityControl() {
       boolean b = frame.getState();
       return b;
   }

}

//ModelUI.java

public class ModelUI{

   public static void main(String[] args) {
//Creating Electrical assembly of type Assembly
       Assembly electAssembly = new ElectricalAssembly();

       electAssembly.assemble();
       if(electAssembly.qualityControl()){ // Checking the quality whether it returns true or false
      
       }else{
           System.err.println("Electrical Assembler has no quality...");
       }
      
       System.out.println("************************************ ");
       //Creating Steering assembly of type Assembly
       Assembly steerAssembly = new SteeringAssembly();
       steerAssembly.assemble();
       if(steerAssembly.qualityControl()){
          
       }else{
           System.err.println("Steering Assembler has no quality..");
       }
      
      
       System.out.println("************************************ ");

//Creating Engine assembly of type Assembly

       Assembly engineAssembly = new EngineAssembly();
       engineAssembly.assemble();
       if(engineAssembly.qualityControl()){
          
       }else{
           System.err.println("Engine Assembler has no Quality..");
       }
      
       System.out.println("************************************ ");

//Creating Chasis assembly of type Assembly

       Assembly chasisAssembly = new ChasisAssembly();
       chasisAssembly.assemble();
       if(chasisAssembly.qualityControl()){
          
       }else{
           System.err.println("Chasis Assembly has no Quality..");
       }

   }


}

Output:

Electrical Assembly Line
The Starter is:Audio Device
************************************

Steering Assembly Line
The Wheel is: Closed End Axle Nut
************************************

Steering Assembler has no quality..
Engine Assembly Line
The valve is:Globe Valve
Engine Assembler has no Quality..
************************************

Chasis Assembly Line
The Chasis Frame is:Monocoque Chassis