3 Replies - 239 Views - Last Post: 04 May 2013 - 02:50 PM Rate Topic: -----

#1 tc356  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 23-April 13

can't get system exit to work dragon12 project

Posted 04 May 2013 - 07:22 AM

I have everything working but the system.exit(0). It should exit any time remaining if the button is pressed. I'm not sure what to do. Help would be greatly appreciated.

/* Creates the perfect hard-boiled(simulates 12 minutes in boiling water) or soft-boiled egg(simulates 6 minutes in boiling water). Both options require 10 seconds of rinsing under cold water after necessary time for boiling. Allow user to exit any remaining time. */


import java.io.*;
import java.util.*;

public class AdvancedEggMaker
{
	public static void main(String[] args)
	{
		MCU mcu = null;

		try
		{
			mcu = new MCU(new Communicator(args[0]));
		}

		catch (IOException e)
		{
			System.out.println(e);
		}

		mcu.println("SW2 - HB Egg", 0);
		mcu.println("SW3 - SB Egg", 1);

		while (true)
		{
			int sw = mcu.getSwitch();


			if(sw == 2)
			{

				mcu.println("Hard Boiled Egg",0);
				mcu.println("Place Egg in",0);
				mcu.println("boiling water",1);
				mcu.println("then press SW4",0);
				mcu.println("SW5 - Quit",1);
				int sw2 = mcu.getSwitch();
				switch (sw2)
				{
					case 4:
						int t = 720;

						while( t > 0 && sw2==4)
						{

								t = (t - 1);
								mcu.println("Boiling...",0);
								mcu.println((t/60) + "mins left...",1);

						}
						break;


					case 5:

						System.exit(0);
					break;

				}
			}

				 if(sw == 3)
				{

					mcu.println("Soft Boiled Egg",0);
					mcu.println("Place Egg in",0);
					mcu.println("boiling water",1);
					mcu.println("then press SW4",0);
					mcu.println("SW5 - Quit",1);
					int sw2 = mcu.getSwitch();

					switch (sw2)
					{
						case 4:
							int t = 360;

							while( t > 0 && sw2==4)
							{

								t = (t - 1);
								mcu.println("Boiling...",0);
								mcu.println((t/60) + "mins left...",1);


							}
							break;

						case 5:
							System.exit(0);
						break;

					}
				}


			mcu.println("Rinse Egg",0);
			mcu.println("then press SW4",0);
			mcu.println("SW5 - Quit",1);
			int sw3 = mcu.getSwitch();

			if (sw3 == 4)
			{
				double t = 10;
				while ( t > 0.0)
				{
					t = (t - 1);
					mcu.println("Rinsing...",0);
					mcu.println(t + "Secs left...",1);
				}

				 if(sw == 5)
				{
					System.exit(0);
				}
			}
		}
	}
}




Is This A Good Question/Topic? 0
  • +

Replies To: can't get system exit to work dragon12 project

#2 GregBrannon  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2197
  • View blog
  • Posts: 5,224
  • Joined: 10-September 10

Re: can't get system exit to work dragon12 project

Posted 04 May 2013 - 01:47 PM

You're using a third-party ap or interface that few have experience with here, so forgive the lack of response. From your description, why can't you just add a listener to the button that exits when the button is selected? Since it must be more complicated than that (but I'm not sure why it would be), I don't understand what you're asking.
Was This Post Helpful? 0
  • +
  • -

#3 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8325
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: can't get system exit to work dragon12 project

Posted 04 May 2013 - 02:18 PM

What is MCU ?
Where is its Javadoc ?
Was This Post Helpful? 0
  • +
  • -

#4 tc356  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 23-April 13

Re: can't get system exit to work dragon12 project

Posted 04 May 2013 - 02:50 PM

It is used for the dragon board to communicate from computer to board. It is used like System.out.print. The mcu is used to print to display, sound, light sensor, and ect...

Such as: mcu.println("text",0);

Hope that answered your question.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1