forked from nus-cs2113-AY2324S2/tp
-
Notifications
You must be signed in to change notification settings - Fork 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
Add additional attributes to Item class and parameters to add methods #53
Merged
nkotaa
merged 14 commits into
AY2324S2-CS2113T-T09-2:master
from
imanamirshah:feature-AddCommand
Mar 17, 2024
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
73cca85
Add additional attributes to Item class
imanamirshah 86833da
Modify addItem method to take in additional parameters
imanamirshah 037d340
Modify parseAddCommand to handle additional parameters
imanamirshah abfc98d
Modify AddCommand class to include new parameters
imanamirshah 939776d
Add new parameters to AddCommandTest test case
imanamirshah 7dd8cc1
Merge branch 'master' into feature-AddCommand
imanamirshah 6758383
Add new line after each item in inventory list
imanamirshah a6136fd
Modify tests to include new parameters
imanamirshah 8626257
Modify expected output strings for list tests
imanamirshah cdc1af8
Add line separator to expected test outputs
imanamirshah a271ddc
Modify length of code to comply with Java coding standards
imanamirshah 909ecb6
Modify new line generator in toString method
imanamirshah c488d21
Merge branch 'master' into feature-AddCommand
imanamirshah a0dfa4f
Remove additional new line in expected output
imanamirshah File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,26 +4,42 @@ | |
import seedu.binbash.ItemList; | ||
|
||
public class AddCommand extends Command { | ||
public static final Pattern COMMAND_FORMAT = Pattern.compile( | ||
"add\\s+n/(?<itemName>.+?)\\s+d/(?<itemDescription>.+)" | ||
); | ||
|
||
public static final Pattern COMMAND_FORMAT = | ||
Pattern.compile("add\\s+n/(?<itemName>.+?)\\s+d/(?<itemDescription>.+)\\s+q/(?<itemQuantity>.+)\\s" | ||
+ "+e/(?<itemExpirationDate>.+)+s/(?<itemSalePrice>.+)+c/(?<itemCostPrice>.+)"); | ||
private final String itemName; | ||
private final String itemDescription; | ||
private final int itemQuantity; | ||
private final String itemExpirationDate; | ||
private final double itemSalePrice; | ||
private final double itemCostPrice; | ||
|
||
public AddCommand(ItemList itemList, String itemName, String itemDescription) { | ||
public AddCommand(ItemList itemList, String itemName, String itemDescription, int itemQuantity, | ||
String itemExpirationDate, double itemSalePrice, double itemCostPrice) { | ||
super(itemList); | ||
this.itemName = itemName; | ||
this.itemDescription = itemDescription; | ||
this.itemQuantity = itemQuantity; | ||
this.itemExpirationDate = itemExpirationDate; | ||
this.itemSalePrice = itemSalePrice; | ||
this.itemCostPrice = itemCostPrice; | ||
|
||
Comment on lines
+18
to
+27
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This constructor appears needlessly verbose. Perhaps we could define it with an Item parameter instead. i.e |
||
commandLogger.fine(String.format( | ||
"Creating Add Command... ItemName: %s , ItemDescription: %s", | ||
"Creating Add Command... itemName: %s, itemDescription: %s, itemQuantity: %d, itemExpirationDate: %s" | ||
+ "itemSalePrice: %f, itemCostPrice: %f", | ||
itemName, | ||
itemDescription | ||
itemDescription, | ||
itemQuantity, | ||
itemExpirationDate, | ||
itemSalePrice, | ||
itemCostPrice | ||
)); | ||
} | ||
|
||
@Override | ||
public String execute() { | ||
return itemList.addItem(itemName, itemDescription); | ||
return itemList.addItem(itemName, itemDescription, itemQuantity, itemExpirationDate, | ||
itemSalePrice, itemCostPrice); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
There might be too many variables. We could look into defining sub-classes of Item to keep this list minimal in the future. Ex.
Perishable extends Item