Cześć,
Mam podany poniższy kawałek kodu i na jego podstawie muszę podać stany stosu po wykonaniu się linii 1 i 2. Stany stosu zapisujemy jako listy par składających się z nazwy zmiennej oraz jej wartości np: [(x,7) , (this,o1)] .Wie ktoś może jaki będzie wynik ?
public class B {
double balance = 0;
public void credit(double amount){
balance = balance + amount;
}
public void debit(double amount){
balance = balance - amount; //(1)
}
public void transfer(B target, double amount){
this.debit(amount);
target.credit(amount); //(2)
}
public static void main(String[] args){
B x1 = new B();
B x2 = new B();
x1.transfer(x2,1);
}
}