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

JAVA Need help getting the output of this code to be, by adding another Interfac

ID: 3865929 • Letter: J

Question

JAVA
Need help getting the output of this code to be, by adding another Interface class :

Pumping down chamber...
Chamber pumped down and @ 0 torr.
HiVac turbo spinning up...
HiVac turbo @ speed.
Gate valves opening...
All gate valves open.
Heater power on...
Heater starting...
Heater at operating temperature.
System ready for production.

This is the current code:

package interfaceSample;

import java.util.ArrayList;
import java.util.Scanner;
//Imports
//Begin Class Interface
public class Interface {

    //Begin Main Method
    public static void main(String[] args) {

        /* Variable */
        String ans;

        /* New scanner object */
        Scanner yn = new Scanner(System.in);

        /* Create new instance of subclass */
        ShutDown object = new ShutDownSystem();

        System.out.print("Shutdown HiVac chamber? Y or N ->: ");
        ans = yn.nextLine();
        if (ans.equalsIgnoreCase("n")) {
            System.out.println("Shut down process canceled.");
        } else if (ans.equalsIgnoreCase("y")) {
            object.shutDown(); /* Call shutdown method */
        } else {
            System.out.println("You must enter either Y or N");
        }
    } //End Main Method
} //End Class Interface

package interfaceSample;
//Imports
//Begin Subclass ShutDownSystem
public class ShutDownSystem implements ShutDown, Suspend {

    /**
     * Implementation of the Shutdown interface
     */
    @Override
    public void shutDown() {
        /* Calls to methods */
        shutDown_Heater();
        shutdown_GateValves();
        shutdown_Turbo();
        shutDown_Evacuate();
        suspend();
    }

    /**
     * Implementation of the Suspend interface
     */
    @Override
    public void suspend() {
        /* Call to method */
        suspend_Production();
    }

    /**
     * Heater shutdown method used to turn off heaters
     */
    private void shutDown_Heater() {
        System.out.println("Heater shutting down...");
        /* Code that runs a heater shutdown process call here */
        System.out.println("Heater power off...");
        System.out.println("Heater at ambient temperature.");
    }

    /**
     * Gate valve shutdown method to close gate valves
     */
    private void shutdown_GateValves() {
        System.out.println("Gate valves closing...");
        /* Code that closes gate valves call here */
        System.out.println("All gate valves closed.");
    }

    /**
     * Turbo shutdown method to shutdown HiVac turbo
     */
    private void shutdown_Turbo() {
        System.out.println("HiVac turbo spinning down...");
        /* Code that runs turbo shutdown process call here */
        System.out.println("HiVac turbo spun down Currently @ 0.0 rpm.");
    }

    /**
     * Evacuate method to bring chamber to atmosphere
     */
    private void shutDown_Evacuate() {
        System.out.println("Pressure release valve on HiVac chamber opening...");
        /* Code that runs pressure release process call here */
        System.out.println("Pressure @ 1 atmosphere (760 torr) Safe to open chamber.");
    }

    /**
     * Suspend method used to suspend production line
     */
    private void suspend_Production() {
        /* Code that calls suspend production line process call here */
        System.out.println("The production line has been suspended.");
    }

} //End Subclass ShutDownSystem

package interfaceSample;

public interface ShutDown {
    public void shutDown();
}
package interfaceSample;

interface Suspend {
    public void suspend();
}

This is the current Output

Shutdown HiVac chamber? Y or N ->: y
Heater shutting down...
Heater power off...
Heater at ambient temperature.
Gate valves closing...
All gate valves closed.
HiVac turbo spinning down...
HiVac turbo spun down
Currently @ 0.0 rpm.
Pressure release valve on HiVac chamber opening...
Pressure @ 1 atmosphere (760 torr)
Safe to open chamber.
The production line has been suspended.

Explanation / Answer

Added StartInterface.java, StartUpSystem.java and interface StartUp.java, Below are the details:

StartInterface.java

package interfaceSample;

import java.util.Scanner;

public class StartInterface {
//Begin Main Method
public static void main(String[] args) {
/* Variable */
String ans;
/* New scanner object */
Scanner yn = new Scanner(System.in);
/* Create new instance of subclass */
StartUpSystem object = new StartUpSystem();
System.out.print("Startup HiVac chamber? Y or N ->: ");
ans = yn.nextLine();
if (ans.equalsIgnoreCase("n")) {
System.out.println("Start up process canceled.");
} else if (ans.equalsIgnoreCase("y")) {
object.startUp(); /* Call startup method */
} else {
System.out.println("You must enter either Y or N");
}
//close the scanner
yn.close();
} //End Main Method


}

StartUpSystem.java

package interfaceSample;

//Begin Subclass StartUpSystem

public class StartUpSystem implements StartUp{

/**

* Implementation of the StartUp interface

*/

@Override

public void startUp() {

/* Calls to methods */

startUp_Chamber();

startUp_Turbo();

startup_GateValves();

startUp_Heater();

start_Production();

}

  

/**

* start method to bring chamber to atmosphere

*/

private void startUp_Chamber() {

System.out.println("Pumping down chamber...");

/* Code that runs pressure release process call here */

System.out.println("Chamber pumped down and @ 0 torr.");

}

/**

* Heater startup method used to turn off heaters

*/

private void startUp_Heater() {

System.out.println("Heater Power on...");

/* Code that runs a heater startup process call here */

System.out.println("Heater starting...");

System.out.println("Heater at operating temperature.");

}

/**

* Gate valve startup method to close gate valves

*/

private void startup_GateValves() {

System.out.println("Gate valves Opening...");

/* Code that opens gate valves call here */

System.out.println("All gate valves open.");

}

/**

* Turbo startup method to start HiVac turbo

*/

private void startUp_Turbo() {

System.out.println("HiVac turbo spinning Up...");

/* Code that runs turbo start up process call here */

System.out.println("HiVac turbo @ speed.");

}

  

/**

* Start method used to start production line

*/

private void start_Production() {

/* Code that calls start production line process call here */

System.out.println("System ready for production.");

}

} //End Subclass StartupSystem

Interface StartUp.java

package interfaceSample;

public interface StartUp {

public void startUp();

}

Sample Output:

Startup HiVac chamber? Y or N ->: y
Pumping down chamber...
Chamber pumped down and @ 0 torr.
HiVac turbo spinning Up...
HiVac turbo @ speed.
Gate valves Opening...
All gate valves open.
Heater Power on...
Heater starting...
Heater at operating temperature.
System ready for production.