Hello, I'm trying to make a very basic + - calculator in java using constructors after watching thenewboston video tutorial I tried to experiment with it. My litle project is almost finished my only problem is that the boolean I use is being reset after I assign it. If someone could take a look at I would really appriciate it.
Also ignore the names of the class didn't bother to change it after the tutorial video.
package bucky;
public class tuna {
private double num1;
private double num2;
private double awnser;
public boolean plus;
public tuna(double numbr1,double numbr2){
num1 = numbr1;
num2 = numbr2;
}
public tuna(String opr) {
if(opr.contentEquals("+")){
plus = true;
}
else if(opr.contentEquals("-")){
plus = false;
}
}
public void saying(){
System.out.print(plus);
if(plus == true){
awnser = num1 + num2;
}else if(plus == false){
awnser = num1 - num2;
}
System.out.println(awnser);
}
}