Kleine Abänderung im Code, und fertigstellung von Tests
parent
4a67ef364f
commit
f7dc27121c
|
|
@ -7,5 +7,22 @@
|
|||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module-library">
|
||||
<library name="JUnit6">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter/6.0.0/junit-jupiter-6.0.0.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-api/6.0.0/junit-jupiter-api-6.0.0.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/opentest4j/opentest4j/1.3.0/opentest4j-1.3.0.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/junit/platform/junit-platform-commons/6.0.0/junit-platform-commons-6.0.0.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/apiguardian/apiguardian-api/1.1.2/apiguardian-api-1.1.2.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/jspecify/jspecify/1.0.0/jspecify-1.0.0.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-params/6.0.0/junit-jupiter-params-6.0.0.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-engine/6.0.0/junit-jupiter-engine-6.0.0.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/junit/platform/junit-platform-engine/6.0.0/junit-platform-engine-6.0.0.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
</component>
|
||||
</module>
|
||||
|
|
@ -17,13 +17,24 @@ double gesamtPreis;
|
|||
this.versandkosten = versandkosten;
|
||||
this.anteil7 = anteil7;
|
||||
this.anteil19 = anteil19;
|
||||
if(gesamtPreis >= 500.0) {
|
||||
this.gesamtPreis = gesamtPreis - versandkosten;}
|
||||
else {
|
||||
this.gesamtPreis = gesamtPreis;
|
||||
}
|
||||
}
|
||||
|
||||
public void bestellbestätigung(){
|
||||
System.out.println("Bestellungbestätigung: \n" + name);
|
||||
System.out.println("Der Gesamt Preis ihrer Bestellung berträgt " + (gesamtPreis) + "€, davon " + versandkosten +"€ Versandkosten");
|
||||
System.out.println(" (inkl. MwSt. 7%: " + anteil7 + " , MwSt. 19%: " + anteil19 + "€, Netto: " + (versandkosten-(anteil7 + anteil19)) + "€ \n");
|
||||
System.out.println("Der Gesamt Preis ihrer Bestellung berträgt ");
|
||||
if(gesamtPreis >= 500.0) {
|
||||
gesamtPreis -= versandkosten;
|
||||
System.out.print(gesamtPreis + "€, und das Versankostenfrei, da Ihre Bestellung über 500€ kostet\n");
|
||||
}
|
||||
else {
|
||||
System.out.print(gesamtPreis + "€, davon " + versandkosten + " Versandkosten");
|
||||
System.out.println(" (inkl. MwSt. 7%: " + anteil7 + " , MwSt. 19%: " + anteil19 + "€, Netto: " + (versandkosten - (anteil7 + anteil19)) + "€ \n");
|
||||
}
|
||||
System.out.println("Ihre Bestellung wurde erflogreich aufgenommen und wird an " + adresse + " geliefert.");
|
||||
System.out.println("Die Bestellung wird in 5-7 Werktagen bei Ihnen eintreffen. \nVielen Dank für Ihre Bestellung!");
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,14 @@
|
|||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class BestellungTest {
|
||||
|
||||
@Test
|
||||
void testBestellung(){
|
||||
Bestellung bestellung = new Bestellung("Igor", "Strasse", 19.95, 0.5, 0.9, 520);
|
||||
|
||||
assertEquals(500.05, bestellung.gesamtPreis);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class ProduktTest {
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
|
||||
void testConstructor(){
|
||||
Produkt produkt1 = new Produkt(1, "IPhone", 0.7, 649.99, 19, 2);
|
||||
Produkt produkt2 = new Produkt(2, "MacBook", 8.5, 829.99, 19, 5);
|
||||
|
||||
assertEquals(1, produkt1.getProduktNr());
|
||||
assertEquals(2, produkt2.getProduktNr());
|
||||
|
||||
assertEquals("IPhone", produkt1.getName());
|
||||
assertEquals("MacBook", produkt2.getName());
|
||||
|
||||
assertEquals(0.7, produkt1.getGewicht());
|
||||
assertEquals(8.5, produkt2.getGewicht());
|
||||
|
||||
assertEquals(649.99, produkt1.getPreis());
|
||||
assertEquals(829.99, produkt2.getPreis());
|
||||
|
||||
assertEquals(19, produkt1.getMwSteuer());
|
||||
assertEquals(19, produkt2.getMwSteuer());
|
||||
|
||||
assertEquals(2, produkt1.getLagerbestand());
|
||||
assertEquals(5, produkt2.getLagerbestand());
|
||||
|
||||
assertEquals("1, IPhone, 0.7, 649.99, 19, 2", produkt1.toString());
|
||||
assertEquals("2, MacBook, 8.5, 829.99, 19, 5", produkt2.toString());
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue