Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 783a0fb

Browse files
committed
Dodano logike sumowania wartości koszyka
1 parent e1f9762 commit 783a0fb

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

AddProductToBucket.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,26 @@ static void Add(String line){
2222
}
2323

2424
static void ShowBucket(){
25-
25+
double orderValue = 0.0;
26+
;
27+
2628

2729
for(int i = 0; i<ProductData.products.size(); i++){
2830
for(int j =0; j< productsNumberArray.length; j++ ){
29-
31+
3032
if(ProductData.products.get(i).id == productsNumberArray[j] ){
31-
System.out.println(ProductData.products. get(i).prodName);
33+
34+
System.out.println(ProductData.products.get(i).prodName + " ---> " + ProductData.products.get(i).price + " zł");
35+
orderValue += ProductData.products.get(i).price;
36+
3237
}
3338
}
34-
35-
39+
3640
}
3741

42+
System.out.println(" ");
43+
System.out.println("Wartość koszyka ---> " + orderValue + " zł");
44+
3845
}
3946

4047
}

MenuPrinter.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ static void printMainMenu(){
99
System.out.println(" ");
1010
System.out.println("*** MENU ***");
1111
System.out.println("(1) Pokaż wszystkie produkty");
12-
System.out.println("(2) Filtruj produkty");
13-
System.out.println("(3) Zamknij sklep!");
12+
System.out.println("(2) Zamknij sklep!");
1413
System.out.println(" ");
1514
}
1615

@@ -63,7 +62,8 @@ static void printSubMenu(Scanner scanner){
6362
AddProductToBucket.Add(numbersLine);
6463

6564
System.out.println(" ");
66-
ClearConsole.Clean();
65+
System.out.println(" ");
66+
6767
System.out.println("Twój koszyk: ");
6868
AddProductToBucket.ShowBucket();
6969

0 commit comments

Comments
 (0)