|  |  |  | @ -1,4 +1,4 @@ | 
			
		
	
		
			
				
					|  |  |  |  | package net.mightypork.semestralka; | 
			
		
	
		
			
				
					|  |  |  |  | package net.mightypork.calculator; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | import java.io.File; | 
			
		
	
	
		
			
				
					|  |  |  | @ -17,7 +17,7 @@ import net.mightypork.rcalc.numbers.Fraction; | 
			
		
	
		
			
				
					|  |  |  |  |  */ | 
			
		
	
		
			
				
					|  |  |  |  | public class CalculatorInteractive implements Runnable { | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 	/** Rcalc Session used by the calculator */ | 
			
		
	
		
			
				
					|  |  |  |  | 	/** RCalc Session used by the calculator */ | 
			
		
	
		
			
				
					|  |  |  |  | 	private RCalcSession session = new RCalcSession(); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 	/** Show results as fractions */ | 
			
		
	
	
		
			
				
					|  |  |  | @ -42,17 +42,18 @@ public class CalculatorInteractive implements Runnable { | 
			
		
	
		
			
				
					|  |  |  |  | 		 + "Commands:\n" | 
			
		
	
		
			
				
					|  |  |  |  | 		 + "\thelp - show this help\n" | 
			
		
	
		
			
				
					|  |  |  |  | 		 + "\texit - quit the calculator\n" | 
			
		
	
		
			
				
					|  |  |  |  | 		 + "\tdebug - toggle debug mode (default off)\n" | 
			
		
	
		
			
				
					|  |  |  |  | 		 + "\tdecimal - toggle decimal/fractional output\n" | 
			
		
	
		
			
				
					|  |  |  |  | 		 + "\tvars - print a list of variables\n" | 
			
		
	
		
			
				
					|  |  |  |  | 		 + "\tdebug - toggle debug mode (default off)\n" | 
			
		
	
		
			
				
					|  |  |  |  | 		 + "\tutest - perform RCalc unit tests\n" | 
			
		
	
		
			
				
					|  |  |  |  | 		 + "\tload filename - execute commands from a file\n" | 
			
		
	
		
			
				
					|  |  |  |  | 		 + "\t\t(Expressions from the file can use/change variables)\n" | 
			
		
	
		
			
				
					|  |  |  |  | 		 + "\n" | 
			
		
	
		
			
				
					|  |  |  |  | 		 + "Mathematical operations, syntax\n" | 
			
		
	
		
			
				
					|  |  |  |  | 		 + "\tSupported: + - * / % ^ ! ( )\n" | 
			
		
	
		
			
				
					|  |  |  |  | 		 + "\tMultiplication sign can be omitted where it makes sense.\n" | 
			
		
	
		
			
				
					|  |  |  |  | 		 + "\tAlong with fractions, decimal-point format works too.\n" | 
			
		
	
		
			
				
					|  |  |  |  | 		 + "\tUse 'a/b' syntax to express a fraction.\n" | 
			
		
	
		
			
				
					|  |  |  |  | 		 + "\tDecimal-point numbers are supported, too.\n" | 
			
		
	
		
			
				
					|  |  |  |  | 		 + "\n" | 
			
		
	
		
			
				
					|  |  |  |  | 		 + "Variables\n" | 
			
		
	
		
			
				
					|  |  |  |  | 		 + "\tAssign a variable:\n" | 
			
		
	
	
		
			
				
					|  |  |  | @ -102,6 +103,9 @@ public class CalculatorInteractive implements Runnable { | 
			
		
	
		
			
				
					|  |  |  |  | 				} | 
			
		
	
		
			
				
					|  |  |  |  | 			} | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 			// can't use a switch on strings because of java 6 :(
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 			if (expr.equals("exit")) { // quit
 | 
			
		
	
		
			
				
					|  |  |  |  | 				System.out.println("Exit."); | 
			
		
	
		
			
				
					|  |  |  |  | 				return; | 
			
		
	
	
		
			
				
					|  |  |  | @ -109,6 +113,10 @@ public class CalculatorInteractive implements Runnable { | 
			
		
	
		
			
				
					|  |  |  |  | 			} else if (expr.equals("help")) { // show help
 | 
			
		
	
		
			
				
					|  |  |  |  | 				System.out.println(helpMessage); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 			} else if (expr.equals("utest")) { // show help
 | 
			
		
	
		
			
				
					|  |  |  |  | 				Runnable r = new Tests(); | 
			
		
	
		
			
				
					|  |  |  |  | 				r.run(); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 			} else if (expr.equals("debug")) { // toggle debug mode
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 				if (session.isDebug()) { |