forked from nusCS2113-AY1920S1/PersonalAssistant-Duke
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #39 from saradj/b-genericList
Adding a GenericList we can use for ingredient list, order list, task list, dish list... renaming Dishes to Dish, and some changes in packages, Also added Fridge Storage(storing the ingrediants already there) and Task Storage
- Loading branch information
Showing
47 changed files
with
639 additions
and
345 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<Diagram> | ||
<ID>JAVA</ID> | ||
<OriginalElement>duke.fridge.Fridge</OriginalElement> | ||
<nodes> | ||
<node x="37.0" y="0.0">duke.ingredient.Ingredient</node> | ||
<node x="0.0" y="257.0">duke.fridge.Fridge</node> | ||
</nodes> | ||
<notes /> | ||
<edges> | ||
<edge source="duke.fridge.Fridge" target="duke.ingredient.Ingredient"> | ||
<point x="-72.75" y="-158.5" /> | ||
<point x="72.75" y="232.0" /> | ||
<point x="91.25" y="232.0" /> | ||
<point x="-54.25" y="103.5" /> | ||
</edge> | ||
</edges> | ||
<settings layout="Hierarchic Group" zoom="1.0904024767801856" x="209.90086910464152" y="286.767461669506" /> | ||
<SelectedNodes /> | ||
<Categories> | ||
<Category>Constructors</Category> | ||
<Category>Methods</Category> | ||
<Category>Inner Classes</Category> | ||
<Category>Fields</Category> | ||
<Category>Properties</Category> | ||
</Categories> | ||
<SCOPE>All</SCOPE> | ||
<VISIBILITY>private</VISIBILITY> | ||
</Diagram> | ||
|
Empty file.
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
@startuml | ||
|
||
title __DUKE's Component Diagram__\n | ||
|
||
|
||
|
||
right footer | ||
|
||
|
||
PlantUML diagram generated by SketchIt! (https://bitbucket.org/pmesmeur/sketch.it) | ||
For more information about this tool, please contact [email protected] | ||
endfooter | ||
|
||
@enduml |
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 |
---|---|---|
|
@@ -33,4 +33,4 @@ public void clearList() { | |
public String toString(Dishes dish) { | ||
return dish.getDishname(); | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package duke.command; | ||
|
||
import duke.exception.DukeException; | ||
import duke.list.GenericList; | ||
import duke.storage.Storage; | ||
import duke.ingredient.*; | ||
import duke.task.TaskList; | ||
import duke.ui.Ui; | ||
|
||
/** | ||
* Represents a specific {@link Cmd} used to find a String occurring in the {@link TaskList}. | ||
*/ | ||
public class FindIngredientCommand extends Cmd<Ingredient> { | ||
|
||
private String toFind; | ||
|
||
public FindIngredientCommand(String toFind) { | ||
this.toFind = toFind; | ||
} | ||
|
||
|
||
|
||
@Override | ||
public void execute(GenericList<Ingredient> tasklist, Ui ui, Storage storage) throws DukeException { | ||
|
||
} | ||
} |
37 changes: 20 additions & 17 deletions
37
src/main/java/duke/command/dishesCommand/AddDishCommand.java
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 |
---|---|---|
@@ -1,54 +1,57 @@ | ||
package duke.command.dishesCommand; | ||
|
||
import duke.Dishes.DishList; | ||
import duke.Dishes.Dishes; | ||
import duke.command.ingredientCommand.AddCommand; | ||
import duke.dish.DishList; | ||
import duke.dish.Dish; | ||
import duke.command.Cmd; | ||
import duke.exception.DukeException; | ||
import duke.storage.Storage; | ||
import duke.ui.Ui; | ||
|
||
public class AddDishCommand extends Cmd<DishList> { | ||
public class AddDishCommand extends AddCommand<Dish> { | ||
|
||
private Dishes dish; | ||
private Dish dish; | ||
private int amount; | ||
private int Nb; | ||
|
||
public AddDishCommand(Dishes dish, int amount) { | ||
|
||
public AddDishCommand(Dish dish, int amount) { | ||
super(dish); | ||
this.dish = dish; | ||
this.amount = amount; | ||
} | ||
|
||
@Override | ||
public void execute(DishList dish1, Ui ui, Storage storage) throws DukeException { | ||
public void execute(DishList dishList, Ui ui, Storage storage) throws DukeException { | ||
boolean flag = true; | ||
try { | ||
if(dish1.getSize() == 0) { | ||
dish1.addDish(dish); | ||
dish1.getDish(0).setNumberOfOrders(amount); | ||
if(dishList.size() == 0) { | ||
dishList.addEntry(dish); | ||
dishList.getEntry(0).setNumberOfOrders(amount); | ||
ui.showAddedDishes(dish.getDishname(), amount); | ||
} | ||
else { | ||
for( int i = 0; i < dish1.getSize(); i++) { | ||
if(dish1.getDish(i).getDishname().equals(dish.getDishname())){ | ||
for( int i = 0; i < dishList.size(); i++) { | ||
if(dishList.getEntry(i).getDishname().equals(dish.getDishname())){ | ||
Nb = i; | ||
flag = false; //dish already exist in list | ||
break; | ||
} | ||
} | ||
if(flag) { | ||
dish1.addDish(dish); // add dish into list found in dishes class | ||
dish1.getDish(dish1.getSize() - 1).setNumberOfOrders(amount); | ||
ui.showAddedDishes(dish.getDishname(), dish1.getDish(dish1.getSize() - 1).getTotalNumberOfOrders()); | ||
dishList.addEntry(dish); // add dish into list found in dishes class | ||
dishList.getEntry(dishList.size() - 1).setNumberOfOrders(amount); | ||
ui.showAddedDishes(dish.getDishname(), dishList.getEntry(dishList.size() - 1).getTotalNumberOfOrders()); | ||
} | ||
else { | ||
dish1.getDish(Nb).setNumberOfOrders(amount); | ||
dishList.getEntry(Nb).setNumberOfOrders(amount); | ||
System.out.println("\t your updated orders:\n\t " | ||
+ dish.getDishname() + "\t amount: " + | ||
String.valueOf(dish1.getDish(Nb).getTotalNumberOfOrders())); | ||
String.valueOf(dishList.getEntry(Nb).getTotalNumberOfOrders())); | ||
} | ||
} | ||
} catch (Exception e) { | ||
throw new DukeException("unable to add dish"); | ||
} | ||
} | ||
|
||
} |
20 changes: 12 additions & 8 deletions
20
src/main/java/duke/command/dishesCommand/AddIngredient.java
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
12 changes: 7 additions & 5 deletions
12
src/main/java/duke/command/dishesCommand/DeleteDishCommand.java
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
16 changes: 9 additions & 7 deletions
16
src/main/java/duke/command/dishesCommand/ListDishCommand.java
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.