-
Notifications
You must be signed in to change notification settings - Fork 3
Change type to var #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 30 commits
bc0b98d
eb3934e
e85219c
82964a0
410e80c
11190ad
f02720e
54cd243
db6ae4a
ca7a5f9
ebe2311
832d1ed
a6363ec
f6701fe
844c366
3588390
04fcb79
6810e52
28c9a88
9be2a4e
f35bbeb
79f2e79
4d84e10
6eb407c
04ee4c9
362ce7d
fa23796
446951c
4050880
d02ffb4
4c1865d
3dde365
bbaf053
4a07108
e6c496d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,3 @@ | ||
| /** | ||
| * | ||
| */ | ||
| package posters.cucumber.support; | ||
|
|
||
| import java.util.ArrayList; | ||
|
|
@@ -38,9 +35,8 @@ public Product addProduct(Product product) | |
| // increase amount of product if already there or add the whole product | ||
| if (products.contains(product)) | ||
| { | ||
| Product updatedProduct = products.get(products.indexOf(product)); | ||
| updatedProduct.setAmount(updatedProduct.getAmount() + 1); | ||
| return updatedProduct; | ||
|
|
||
| return updateCountOfProduct(product.getName(), product.getSize(), product.getStyle(), product.getAmount() + 1); | ||
| } | ||
| else | ||
| { | ||
|
|
@@ -49,15 +45,32 @@ public Product addProduct(Product product) | |
| } | ||
| } | ||
|
|
||
| public void removeProduct(String productName, String style, String size) | ||
| public Product getProductFromArrayList(String name, String size, String style) | ||
| { | ||
| int i = 0; | ||
| for (Product product : products) | ||
| { | ||
| if (product.getName().equals(productName) && product.getSize().equals(size) | ||
| && product.getStyle().equals(style)) | ||
| if (product.getName().equals(name) && product.getSize().equals(size) && product.getStyle().equals(style)) | ||
| { | ||
| products.remove(product); | ||
| i = products.indexOf(product); | ||
| } | ||
| } | ||
| return products.get(i); | ||
| } | ||
|
|
||
| public Product updateCountOfProduct(String name, String size, String style, int amount) | ||
| { | ||
| var updateProducht = getProductFromArrayList(name, size, style); | ||
|
||
| String unitPrice = updateProducht.getUnitPrice(); | ||
| products.remove(products.indexOf(updateProducht)); | ||
| updateProducht = new Product(name, unitPrice, style, size, amount); | ||
| products.add(updateProducht); | ||
| return updateProducht; | ||
| } | ||
|
|
||
| public void removeProduct(String name, String style, String size) | ||
| { | ||
| var updateProducht = getProductFromArrayList(name, size, style); | ||
|
||
| products.remove(products.indexOf(updateProducht)); | ||
|
||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove unneeded new line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done