Commit c6d1160f by Patryk Czarnik

Klasa Konto i pierwsze testy

parent 83a5faf6
......@@ -6,5 +6,6 @@
</attributes>
</classpathentry>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5"/>
<classpathentry kind="output" path="bin"/>
</classpath>
package konto;
public class Konto {
private final int numer;
private final String wlasciciel;
private int saldo;
public Konto(int numer, String wlasciciel, int saldo) {
this.numer = numer;
this.wlasciciel = wlasciciel;
this.saldo = saldo;
}
public Konto(int numer, String wlasciciel) {
this(numer, wlasciciel, 0);
}
public int getNumer() {
return numer;
}
public String getWlasciciel() {
return wlasciciel;
}
public int getSaldo() {
return saldo;
}
@Override
public String toString() {
return "Konto nr " + numer + ", wł. " + wlasciciel + ", saldo " + saldo;
}
}
package konto;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
class KontoTest {
@BeforeEach
void setUp() throws Exception {
}
@Test
void testToString() {
Konto konto = new Konto(123, "Ala Kowalska", 1200);
assertEquals("Konto nr 123, wł. Ala Kowalska, saldo 1200", konto.toString());
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment