parent
c545955856
commit
1fa6523125
|
|
@ -3,13 +3,24 @@ package de.th_mannheim.informatik.shop.backend;
|
|||
public class Produkt {
|
||||
String name;
|
||||
double preis;
|
||||
|
||||
|
||||
public Produkt(String name, double preis) {
|
||||
this.name = name;
|
||||
this.preis = preis;
|
||||
}
|
||||
|
||||
|
||||
public String toString() {
|
||||
return this.name + " " + this.preis + " Euro.";
|
||||
}
|
||||
|
||||
public boolean equals(Object o) {
|
||||
if (!(o instanceof Produkt))
|
||||
return false;
|
||||
|
||||
if (!this.name.equals(((Produkt)o).name)
|
||||
|| this.preis != ((Produkt)o).preis)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,17 @@
|
|||
package de.th_mannheim.informatik.shop.backend;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class ProduktTest {
|
||||
|
||||
@Test
|
||||
void test() {
|
||||
Produkt p1 = new Produkt("Wein", 3.50);
|
||||
Produkt p2 = new Produkt("Wein", 3.50);
|
||||
|
||||
assertTrue(p1.equals(p2));
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue