package Software.Task;

import java.util.Scanner;

import toolBox.Print;
import Hardware.Computer;
import Software.Program;

public class Console extends Task{
	
	public Program program;
	public boolean ROOT = false;

	public Console(Computer computer, String name, int minUsage,
			int space) {
		super(computer, name, "exe", minUsage, space, false);
	}
	
	public Scanner reader = new Scanner(System.in);
	
	public void start() {
		if(computer.getRam().getTotalRam() - computer.getRam().getUsedRAM() > minUsage && computer.on) {
			Print.info("Starting " + (computer.getOs().getName() + ".task.start.console.exe"));
			computer.getRam().addUsedRAM(minUsage);
			Print.info("---------------------------------------------------");
			Print.info("       Welcome to Command Line by Minicream!");
			Print.info("---------------------------------------------------");
			if (ROOT) {
				Print.info("test at Console/line 29");
			}
			main();
		} else {
			if (computer.on) {
				Print.info("---------------------------------------------------");
				Print.info("Error when trying to start: " + (computer.getOs().getName() + ".task.start.console.exe"));
				Print.info("---------------------------------------------------");
				Print.info("ERROR Type:  NO_RAM_FOR_TASK");
				Print.info("ERROR Info:  Total  RAM: " + computer.getRam().getTotalRam());
				Print.info("             Used   RAM: " + computer.getRam().getUsedRAM());
				Print.info("             Needed RAM: " + minUsage);
				Print.info("---------------------------------------------------");
				Print.info("Error happendes when the computer doesn't have");
				Print.info("enoght RAM to run an task! Upgrade your RAM or");
				Print.info("stop unused tasks to avoid getting the error! ");
				Print.info("---------------------------------------------------");
			} else {
				Print.info("Coul'd not load task! Computer is not turned on!");
			}
		}
	}
	
	public void stop() {
		if(ROOT) {
			Print.info("Starting " + (computer.getOs().getName() + ".task.kill.console.exe"));
		}
		computer.getRam().addUsedRAM(-minUsage);
	}
	
	/** The App Itself **/
	
	public void main() {
		String[] action = reader.next().split(";");
		
		if(action[0].equals("close")) {
			stop();
		}else if(action[0].equals("run") && !action[1].equals("console") && !action[1].equals("os")){
			program = new Program(action[1], computer);
			main();
		}else if(action[0].equals("ROOT_OUTPUT")) {
			if(action[1].equals("true")) {
				computer.ROOT = true;
				Print.info("ROOT_OUTPUT have enabled!");
				Print.info(computer.getOs().getName() + ".root.IO.out.coreInfo.sys | TRUE [BIN: 0]");
			}else if(action[1].equals("false")){
				Print.info("ROOT_OUTPUT have disabled!");
				computer.ROOT = false;
			}else {
				Print.info("Usage: ROOT_OUTPUT[true/false]! The input " + action[1].toString() + " is invalid!");
			}
		}else {
			Print.info("Problem while trying to run command: Not have permmition/not excist!");
			main();
		}
	}
	
	public boolean isROOT() {
		if(ROOT) {
			return true;
		}else {
			return false;
		}
	}
	
	public void init() {
		ROOT = false;
	}

}

@@ -66,16 +66,41 @@
 .Print;%0A
+import Error.ErrorTypes;%0A
 import H
@@ -208,38 +208,8 @@
 ram;
-%0A%09public boolean ROOT = false;
 %0A%0A%09p
@@ -428,42 +428,36 @@
 %09if(
-computer.getRam().getTotalRam() - 
+!ErrorTypes.NO_RAM_FOR_TASK(
 comp
@@ -473,23 +473,9 @@
 am()
-.getUsedRAM() %3E
+,
  min
@@ -480,16 +480,17 @@
 inUsage 
+)
 && compu
@@ -495,24 +495,48 @@
 puter.on) %7B%0A
+%09%09%09if(computer.ROOT) %7B%0A%09
 %09%09%09Print.inf
@@ -610,16 +610,21 @@
 exe%22));%0A
+%09%09%09%7D%0A
 %09%09%09compu
@@ -868,1046 +868,15 @@
 %0A%09%09%09
-if (ROOT) %7B%0A%09%09%09%09Print.info(%22test at Console/line 29%22);%0A%09%09%09%7D%0A%09%09%09main();%0A%09%09%7D else %7B%0A%09%09%09if (computer.on) %7B%0A%09%09%09%09Print.info(%22---------------------------------------------------%22);%0A%09%09%09%09Print.info(%22Error when trying to start: %22 + (computer.getOs().getName() + %22.task.start.console.exe%22));%0A%09%09%09%09Print.info(%22---------------------------------------------------%22);%0A%09%09%09%09Print.info(%22ERROR Type:  NO_RAM_FOR_TASK%22);%0A%09%09%09%09Print.info(%22ERROR Info:  Total  RAM: %22 + computer.getRam().getTotalRam());%0A%09%09%09%09Print.info(%22             Used   RAM: %22 + computer.getRam().getUsedRAM());%0A%09%09%09%09Print.info(%22             Needed RAM: %22 + minUsage);%0A%09%09%09%09Print.info(%22---------------------------------------------------%22);%0A%09%09%09%09Print.info(%22Error happendes when the computer doesn't have%22);%0A%09%09%09%09Print.info(%22enoght RAM to run an task! Upgrade your RAM or%22);%0A%09%09%09%09Print.info(%22stop unused tasks to avoid getting the error! %22);%0A%09%09%09%09Print.info(%22---------------------------------------------------%22);%0A%09%09%09%7D else %7B%0A%09%09%09%09Print.info(%22Coul'd not load task! Computer is not turned on!%22);%0A%09%09%09%7D
+main();
 %0A%09%09%7D
@@ -900,32 +900,41 @@
 d stop() %7B%0A%09%09if(
+computer.
 ROOT) %7B%0A%09%09%09Print
@@ -1952,140 +1952,8 @@
 %7D%0A%09%0A
-%09public boolean isROOT() %7B%0A%09%09if(ROOT) %7B%0A%09%09%09return true;%0A%09%09%7Delse %7B%0A%09%09%09return false;%0A%09%09%7D%0A%09%7D%0A%09%0A%09public void init() %7B%0A%09%09ROOT = false;%0A%09%7D
 %0A%0A%7D%0A

Update Console.java