Question

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

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\nCurrently @ 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)\nSafe 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.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

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.

Add a comment
Know the answer?
Add Answer to:
JAVA Need help getting the output of this code to be, by adding another Interface class...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Need Help ASAP!! Below is my code and i am getting error in (public interface stack)...

    Need Help ASAP!! Below is my code and i am getting error in (public interface stack) and in StackImplementation class. Please help me fix it. Please provide a solution so i can fix the error. thank you.... package mazeGame; import java.io.*; import java.util.*; public class mazeGame {    static String[][]maze;    public static void main(String[] args)    {    maze=new String[30][30];    maze=fillArray("mazefile.txt");    }    public static String[][]fillArray(String file)    {    maze = new String[30][30];       try{...

  • Java -Create an interface and implement it In the murach.db package, create an interface named IProductDB....

    Java -Create an interface and implement it In the murach.db package, create an interface named IProductDB. This interface should specify this abstract method: public abstract Product get(String productCode); Modify the ProductDB class so it implements the IProductDB interface. Write the code for the new ‘get’ method. Then remove the getProductByCode method. In the Main class, modify the code so it works with the new ProductDB class. This code should create an instance of the IProductDB interface like this: IProductDB db...

  • I need help with adding comments to my code and I need a uml diagram for...

    I need help with adding comments to my code and I need a uml diagram for it. PLs help.... Zipcodeproject.java package zipcodesproject; import java.util.Scanner; import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; public class Zipcodesproject { /** * @param args the command line arguments */ public static void main(String[] args) { Scanner input=new Scanner(System.in); BufferedReader reader; int code; String state,town; ziplist listOFCodes=new ziplist(); try { reader = new BufferedReader(new FileReader("C:UsersJayDesktopzipcodes.txt")); String line = reader.readLine(); while (line != null) { code=Integer.parseInt(line); line =...

  • JAVA Modify the code to create a class called box, wherein you find the area. I...

    JAVA Modify the code to create a class called box, wherein you find the area. I have the code in rectangle and needs to change it to box. Here is my code. Rectangle.java public class Rectangle { private int length; private int width;       public void setRectangle(int length, int width) { this.length = length; this.width = width; } public int area() { return this.length * this.width; } } // CONSOLE / MAIN import java.awt.Rectangle; import java.util.Scanner; public class Console...

  • Show the output of running the class Test in the following code lines: interface A {...

    Show the output of running the class Test in the following code lines: interface A { void print (); } class C ( class B extends C implements A { public void print() { } } class Test { public static void main(String[] args) { B b = new B(); if (b instanceof A) System.out.println("b is an instance of A"); w class Test { public static void main(String[] args) { B b = new B(); if (b instanceof A) System.out.println("b...

  • the code needs to be modifed. require a output for the code Java Program to Implement...

    the code needs to be modifed. require a output for the code Java Program to Implement Insertion Sort import java.util.Scanner; /Class InsertionSort * public class Insertion Sort { /Insertion Sort function */ public static void sort( int arr) int N- arr.length; int i, j, temp; for (i-1; i< N; i++) j-i temp arrli; while (j> 0 && temp < arrli-1) arrli]-arrli-1]; j-j-1; } arrlj] temp; /Main method * public static void main(String [] args) { Scanner scan new Scanner( System.in...

  • JAVA HELP: Directions Write a program that will create an array of random numbers and output...

    JAVA HELP: Directions Write a program that will create an array of random numbers and output the values. Then output the values in the array backwards. Here is my code, I am having a problem with the second method. import java.util.Scanner; import java.util.Random; public class ArrayBackwards { public static void main(String[] args) { genrate(); print(); } public static void generate() { Scanner scanner = new Scanner(System.in);    System.out.println("Seed:"); int seed = scanner.nextInt();    System.out.println("Length"); int length = scanner.nextInt(); Random random...

  • This code is in java. Create a Java class that has the private double data of length, width, and price. Create the gets...

    This code is in java. Create a Java class that has the private double data of length, width, and price. Create the gets and sets methods for the variables. Create a No-Arg constructor and a constructor that accepts all three values. At the end of the class add a main method that accepts variables from the user as input to represent the length and width of a room in feet and the price of carpeting per square foot in dollars...

  • I Need UML Design for the following Java code: Colorable interface: public interface Colorable { //a...

    I Need UML Design for the following Java code: Colorable interface: public interface Colorable { //a void method named howToColor(). void howToColor(); } GeometricObject class: public class GeometricObject { } Sqaure class: public class Square extends GeometricObject implements Colorable{ //side variable of Square double side;    //Implementing howToColor() @Override public void howToColor() { System.out.println("Color all four sides."); }    //setter and getter methods for Square public void setSide(double side) { this.side = side; }    public double getSide() { return...

  • Need help writing Java code for this question. CircleFrame class is provided below. what happen after...

    Need help writing Java code for this question. CircleFrame class is provided below. what happen after u add the code and follow the requirement? It would be nice to be able to directly tell the model to go into wait mode in the same way that the model's notify method is called. (i.e. notify is called directly on the model, whereas wait is called indirectly through the suspended attribute.) Try altering the the actionPerformed method of the SliderListener innner class...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT