/* Andy Schwartz
 * COP3330 Example Class
 * ArithmeticPrinter2
 * 9/1/2006
 *
 *Description: Performs binary arithmetic operations on integers and prints 
 * results. 
 *Modified version: includes instance and class(static) variables
 */
 
 
 public class ArithmeticPrinter2 {
 	
 	//instance variables to keep track of last two numbers operated on
 	private int lastNum1;
 	private int lastNum2;
 	
 	public static int numOperations = 0;//keep track of operations done by any ARP objects 
 	
 	public static void main(String [] args){
 		//entry point into program, used to test methods of class
 		
 		ArithmeticPrinter2 arP = new ArithmeticPrinter2();//creates object
 		ArithmeticPrinter2 arP2 = new ArithmeticPrinter2();//creates another AP object
 		
 		//create two integers to work with:
 		int num1 = 56;
 		int num2 = 23;
 		
 		//call methods to perform simple airthmetic and print results
 		arP.addPrint(num1, num2);
 		//....
 		arP.showLastNums();
 		arP2.showLastNums();//shows last numbers an operation was performed on
 		arP2.subtractPrint(45.1, 10);
 		
 		arP.subtractPrint(num1, num2);
 		arP.multiplyPrint(num1, num2);
 		
 		ArithmeticPrinter2.showNumOperations();
 	}
 	
 	public ArithmeticPrinter2 (){
 		//ocnstructor to create an ArithmeticPrinter object
 		this.lastNum1 = 0;
 		this.lastNum2 = 0;
 	}
 	
 	//////////////////////////////////////////////////////
 	// public instance methods:
 	public void showLastNums(){
 		System.out.println("num1: " + this.lastNum1);
 		System.out.println("num2: " + this.lastNum2);
 	}
 	
 	
 	public int addPrint(int x, int y){
 		//finds the sum of two numbers, prints the result and returns the result
 		numOperations++;
 		this.lastNum1 = x;
 		this.lastNum2 = y;
 		int sum = x + y;
 		System.out.println("The sum is: " + sum);
 		return sum;
 	}
 	
 	public int subtractPrint(double x, double y){
 		//finds the difference(+/-) between two integers, prints and returns result
 		numOperations++;
 		int difference = (int)(x - y);
 		System.out.println("The difference is: " + difference);
 		return difference;
 	}
 	
 	public int multiplyPrint(int x, int y){
 		//finds the product between two integers, prints and returns result
 		numOperations++;
 		int product = x * y;
 		System.out.println("The product is: " + product);
 		return product;
 	}
 	
 	
 	public static void showNumOperations(){
 		//shows last numbers an operation was performed on
 		System.out.println("Number of operations: " + numOperations);
 	}
 	
 	/////////////////////////////////////////////////////
 	//private methods:
 	// (what is something multiple methods do that could be private?)
 }
