mitchwag17
10/24/2018 - 4:21 PM

FirstAgain

public class FirstAgain {

	int a, b;

	public FirstAgain() {
		a = 0;
		b = 0;
	}

	public void setNum1(int num1) {
		a = num1;
	}

	public void setNum2(int num2) {
		b = num2;
	}
	
	public int calcAnswer(){
		
		int answer = a + b;
		return answer;
		
	}
}
public class FirstAgainPart2 {

	int num1, num2;

	public FirstAgainPart2() {

	}

	public void getNumbers(int a, int b) {
		num1 = a;
		num2 = b;
	}

	public int calcAnswer() {
		return (num1 + num2);
	}
}
public class FirstAgainPart3 {

	int num1, num2;
	String myName;

	public FirstAgainPart3(int a, int b, String c) {
		num1 = a;
		num2 = b;
		myName = c;
	}

	public String calcAnswer() {
		return (myName + ", the answer is: " + (num1 + num2) + " meatbag...");
	}
}
import java.util.Scanner;

public class FirstAgainRunner {

	public static void main(String[] args) {
		Scanner scanObj = new Scanner(System.in);

		System.out.print("WHATS YO NAME BUD \n");
		String name = scanObj.next();

		System.out.print("FIRST NUM? ");
		int num1 = scanObj.nextInt();

		System.out.print("SECOND NUM? ");
		int num2 = scanObj.nextInt();

		/*
		FirstAgain myObj = new FirstAgain();
		myObj.setNum1(num1);
		myObj.setNum2(num2);
		
		
		FirstAgainPart2 myObj = new FirstAgainPart2();
		myObj.getNumbers(num1, num2);
		*/
		
		FirstAgainPart3 myObj = new FirstAgainPart3(num1,num2, name);
		
		System.out.print(myObj.calcAnswer());

	}

}