SlideShare a Scribd company logo
project_additions/CuisineType.javaproject_additions/CuisineTy
pe.javapublic enum CuisineType{
ITALIAN, MEXICAN, THAI, AMERICAN, JAPANESE, CHI
NESE, FRENCH, VIETNAMESE,
KOREAN, NONE
}
project_additions/Design_Doc.docx
Display Class
Display
Constructor:
Create panels
Create textBoxes
Actionlisteners
for seach
button
Menu Button
for adding
recipe
Input Class
(sub-class of
Display)
Sorts Input
from Display
Class
ShoppingList
Class
ArrayList:
Recipes
ShoppingList
Constructor:
Initialization of
Objects
addList(recipe)
removeList(recipe)
toString():
formatting
Adds to recipe list
Removes from List
1
Display
Constructor:
Create panels
Create textBoxes
Pantry Class
Pantry Constructor:
Initialization of
Objects
addIngredient
Method(ingredient)
removeIngredient
Method(ingredient)
toString():
formatting
ArrayList:
Ingredients
IF: on the list
Send notification
prompt
Else: not on the
list
Add to the List
Remove from
List
Send notification
prompt
1
Recipe Class
String: Name
ArrayList:
ingredientList
ArrayList:
instructions
Recipe Constructor:
(name, Temperature,
instructions)
ArrayList:
ingredientMeasurements
Enum:
dietType
Enum:
cuisineType
Enum:
mealType
UpdateShoppingList()
Items not in pantry
ImportPhoto(String
filepath)
toString(): formatting
addIngredient(Ingredie
nt ingredient, int
measurement)
removeIngredient(int
ingredientListIndex)
setDietType(Enum
type)
setCuisineType(Enum
type)
addInstruction(String
instruction)
setMealType(Enum
type)
1
RecipeBook Class
RecipeBook
Constructor:
Initialization of
Objects
addRecipe()
removeRecipe()
ArrayList:
Recipes
ArrayList:
SearchResults
Recipe Creation
Removes from
List
Adds to List
Findrecipe
method
(searchtype)
IF by name /
cusineType /
ingredients
THEN by name /
cusineType /
ingredients
1
Ingredient Class
String: Name
String:
Description
importPhoto(String
filepath)
Create and
associate photo
with ingredient
setDecription(String
desc):
Description = desc
FacebookIntegration
Object:
FacebookClient
facebookClient
postRecipe(Recipe
recipe)
facebookClient.publish();
1
project_additions/DietType.javaproject_additions/DietType.java
public enum DietType{
VEGETARIAN, VEGAN, NONE
}
project_additions/Display.javaproject_additions/Display.javaim
port java.awt.BorderLayout;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.io.File;
import javax.swing.Box;
import javax.swing.DefaultListModel;
import javax.swing.DefaultListSelectionModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
importstatic javax.swing.JList.VERTICAL;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTabbedPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
// Date: July 6, 2017
// Authors:
// Purpose: Create a recipe manager
/**
*
*/
publicclassDisplayextendsJFrame{
//global variables
staticfinallong serialVerisionUID =123L;
JTextArea jta =newJTextArea();
staticDefaultListModel listModel, pantryListModel, shoppingLi
stModel ;
JMenuBar menuBar;
JMenu menu, submenu;
JMenuItem menuItem;
JTextField jtf =newJTextField(20);
JButton searchButton =newJButton("Search");
JComboBox<String> jcb =newJComboBox<String>();
JList list, pantryList, shoppingList;
File photoFile =null;
finalJFileChooser fc =newJFileChooser();
JTabbedPane tp =newJTabbedPane();
publicstaticvoid main(String[] args){
Display gui =newDisplay();
}// end main method
//constructor
publicDisplay(){
//setting basic jframe functions
setTitle("Recipe Manager");
setSize(900,600);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
setLocationRelativeTo(null);
//setting text area for recipe
jta.setEditable(false);
JScrollPane jsp =newJScrollPane(jta);
//setting recipe list pane
listModel =newDefaultListModel();
list =newJList(listModel);
list.setLayoutOrientation(VERTICAL);
list.setSelectionMode(DefaultListSelectionModel.SINGL
E_SELECTION);
JScrollPane listpane =newJScrollPane(list);
list.getSelectionModel().addListSelectionListener(e -
> listContents());
//setting pantry list pane
pantryListModel =newDefaultListModel();
pantryList =newJList(pantryListModel);
pantryList.setLayoutOrientation(VERTICAL);
pantryList.setSelectionMode(DefaultListSelectionModel.
SINGLE_SELECTION);
JScrollPane pantryListPane =newJScrollPane(pantryList);
//setting shopping list pane
shoppingListModel =newDefaultListModel();
shoppingList =newJList(pantryListModel);
shoppingList.setLayoutOrientation(VERTICAL);
shoppingList.setSelectionMode(DefaultListSelectionMod
el.SINGLE_SELECTION);
JScrollPane shoppingListPane =newJScrollPane(shoppingList);
//setting menu
SetMenuBar();
add(menuBar,BorderLayout.PAGE_START);
//setting the split panes
JSplitPane splitpane =newJSplitPane(JSplitPane.HORIZONTAL
_SPLIT);
splitpane.setRightComponent(jsp);
splitpane.setLeftComponent(listpane);
// setting tabbed panes
tp.add("recipes", splitpane);
tp.add("pantry", pantryListPane);
tp.add("shopping", shoppingListPane);
add(tp);
// add(splitpane,BorderLayout.CENTER);
validate();// validates all components
}// end display constructor
//class for setting menu bar
privatevoidSetMenuBar(){
menuBar =newJMenuBar();
//Recipe Menu
menu =newJMenu("Recipe");
menuBar.add(menu);
menuItem =newJMenuItem("add recipe");
menuItem.addActionListener(e -> recipeForm());
menu.add(menuItem);
menuItem =newJMenuItem("edit recipe");
menuItem.addActionListener(e -> editForm());
menu.add(menuItem);
menuItem =newJMenuItem("remove selected recipe");
menuItem.addActionListener(e -> editForm());
menu.add(menuItem);
//Pantry Menu
//Pantry Menu
menu =newJMenu("Pantry");
menuBar.add(menu);
menuItem =newJMenuItem("Add to Pantry");
menuItem.addActionListener(e ->Input.addToPantry());
menu.add(menuItem);
menuItem =newJMenuItem("Remove from Pantry");
menu.add(menuItem);
//Shopping List Menu
menu =newJMenu("Shopping");
menuBar.add(menu);
menuItem =newJMenuItem("Add selected recipe to list");
menu.add(menuItem);
//Export Menu
menu =newJMenu("Export");
menuBar.add(menu);
menuItem =newJMenuItem("Print");
menu.add(menuItem);
menuItem =newJMenuItem("Social Media");
menu.add(menuItem);
// adding to the right
menuBar.add(Box.createHorizontalGlue());
menuBar.add(searchBar());
}// end setmenubar method
privateJPanel searchBar(){//still working on this
JPanel jp =newJPanel();
jcb.addItem ("Name");
jcb.addItem ("Type");
jcb.addItem ("Ingredients");
jp.add(jtf);
jp.add(jcb);
jp.add(searchButton);
searchButton.addActionListener(e -
>Input.searchRecipe());
return jp;
}// end searchBar method
protectedvoid recipeForm(){
// method for adding recipe
JFrame addFrame =newJFrame("Add Recipe");
JTextField recipeName =newJTextField(20);
JTextField ingredients =newJTextField();
JTextArea instructions =newJTextArea();
JScrollPane scrollpane =newJScrollPane(instructions);
JButton addPicture =newJButton("Add Picture");
addFrame.setLocationRelativeTo(null);
JPanel form =newJPanel(newGridLayout(0,1));
form.add(newJLabel("Recipe Name"));
form.add(recipeName);
form.add(newJLabel("Ingredients delimited by ';'"));
form.add(ingredients);
form.add(newJLabel("Instructions"));
form.add(scrollpane);
form.add(addPicture);
addPicture.addActionListener(e -
> addPhoto(addFrame));
// JPanel Button Panel = new JPanel();
JPanel buttons =newJPanel();
JButton submit =newJButton("Add");
submit.addActionListener(e -
>Input.addRecipe(recipeName.getText(), ingredients.getText(),
instructions.getText(), addFrame)
);
// submit.addActionListener(e -> );
JButton cancel =newJButton("Cancel");
cancel.addActionListener(e -> addFrame.dispose());
buttons.add(submit);
buttons.add(cancel);
form.add(buttons);
addFrame.add(form);
addFrame.pack();
addFrame.setSize(500,500);
addFrame.setVisible(true);
}//end method addRecipe
privatevoid addPhoto(JFrame form){
int returnVal = fc.showOpenDialog(form);
if(returnVal ==JFileChooser.APPROVE_OPTION){
photoFile = fc.getSelectedFile();
}
}
protectedvoid editForm(){
//Object selected = listModel.getElementAt(list.getSelectedInde
x());
JFrame editFrame =newJFrame("Edit Recipe");
JTextField recipeName =newJTextField(20);
JTextField ingredients =newJTextField();
JTextArea instructions =newJTextArea();
JScrollPane scrollpane =newJScrollPane(instructions);
JButton addPicture =newJButton("Add Picture");
editFrame.setLocationRelativeTo(null);
JPanel form =newJPanel(newGridLayout(0,1));
form.add(newJLabel("Recipe Name"));
form.add(recipeName);
form.add(newJLabel("Ingredients delimited by ';'"));
form.add(ingredients);
form.add(newJLabel("Instructions"));
form.add(scrollpane);
// JPanel Button Panel = new JPanel();
form.add(addPicture);
addPicture.addActionListener(e -
> addPhoto(editFrame));
JPanel buttons =newJPanel();
JButton submit =newJButton("Add");
submit.addActionListener(e -
>Input.addRecipe(recipeName.getText(), ingredients.getText(),
instructions.getText(), editFrame)
);
// submit.addActionListener(e -> );
JButton cancel =newJButton("Cancel");
cancel.addActionListener(e -> editFrame.dispose());
buttons.add(submit);
buttons.add(cancel);
form.add(buttons);
editFrame.add(form);
editFrame.pack();
editFrame.setSize(500,500);
editFrame.setVisible(true);
}// end editForm method
protectedvoid removeRecipe(){
}
protectedvoid listContents(){
//lists the contents of the recipe/pantry list/ shopping list
}
protectedvoid addToShoppingList(){
}
// defines the actions for the components
staticclassInput{
protectedstaticvoid searchRecipe(){
// method for searching Recipe
/*
Here a method should be added for searching the recipe.
.. soemthing like
Recipe = search(jcb.getSelected.toString(), jtf.getText()
)
^ that method will return a recipe, so I can add the resul
t later
*/
//return recipe
//set textbox
}// end method searchRecipe
protectedstaticvoid addRecipe(String name,String ingredients,St
ring instruction,JFrame addFrame){
//create a recipe object from this
//photoFile is global
//add object to the list model... be sure to have a toString metho
d with the recipes name
listModel.addElement("test");
addFrame.dispose();
}// end addRecipe method
protectedstaticvoid editRecipe(){
}//end editRecipe form
protectedstaticvoid removeRecipe(){
//removing the selected recope from the list
}
protectedstaticvoid addToPantry(){
String ingredients=JOptionPane.showInputDialog("Add ingredie
nts delimited by ';'");
//takes a string of ingredients and then addes each as an ingredie
nt
}
}// end class input
}// end class Display
project_additions/Ingredient.javaproject_additions/Ingredient.ja
vaimport java.awt.image.BufferedImage;
/**
* Revisions
*
* | Revision # | Date | Description | Name |
* +------------+-------+-----------------------+---------------+
* | 1 | 7/2 | First Draft | Chris |
* +------------+-------+-----------------------+---------------+
* | 1 | 7/9 | Added toString() | Josh |
* +------------+-------+-----------------------+---------------+
*
*/
publicclassIngredient{
publicString ingredientName;
publicBufferedImage photo;
publicString description;
publicIngredient(String name,String desc){
ingredientName = name;
photo =null;
description = desc;
}
@Override
publicString toString(){
return"Ingredient [ingredientName="+ ingredientName +", phot
o="+ photo +", description="+ description
+"]";
}
}
project_additions/MealType.javaproject_additions/MealType.ja
vapublic enum MealType{
BREAKFAST, LUNCH, DINNER, SNACK, BRUNCH, DESS
ERT, NONE
}
project_additions/MeasuredIngredient.javaproject_additions/Me
asuredIngredient.javapublicclassMeasuredIngredientextendsIngr
edient{
publicMeasurementType measurementType;
publicfloat measurementAmount;
publicString specialInstructions;
publicMeasuredIngredient(Ingredient ingredient,MeasurementT
ype type,
float amount,String instructions){
super(ingredient.ingredientName, ingredient.description);
measurementType = type;
measurementAmount = amount;
specialInstructions = instructions;
}
}
project_additions/MeasurementType.javaproject_additions/Meas
urementType.javaimport java.util.EnumSet;
public enum MeasurementType{
CUP, TEASPOON, TABLESPOON, FLUID_OUNCE, MILLI
LITER, LITER, DECILITER,
POUND, OUNCE, MILIGRAM, GRAM, KILOGRAM;
publicstaticEnumSet<MeasurementType> volume =EnumSet.of(
CUP, TEASPOON,
TABLESPOON, FLUID_OUNCE, MILLILITER, LITER
, DECILITER);
publicstaticEnumSet<MeasurementType> mass =EnumSet.of(PO
UND, OUNCE,
MILIGRAM, GRAM, KILOGRAM);
}
project_additions/Pantry.javaproject_additions/Pantry.javaimpor
t java.util.ArrayList;
/**
* Revisions
*
* | Revision # | Date | Description | Name |
* +------------+-------+-----------------------+---------------+
* | 1 | 7/9 | First Draft | Josh |
* +------------+-------+-----------------------+---------------+
*
*/
publicclassPantry{
privateArrayList<Ingredient> ingredients;
publicPantry(Ingredient ingredient){
ingredients =newArrayList<>();
ingredients.add(ingredient);
}
publicPantry(){
}
publicvoid addIngredient(Ingredient ingredient){
if(ingredients.contains(ingredient)){
System.out.println("Don't Add!");
}else{
ingredients.add(ingredient);
}
}
publicString removeIngredient(Ingredient ingredient){
if(ingredients.contains(ingredient)){
ingredients.remove(ingredient);
return"Removed";
}
return"Not found";
}
@Override
publicString toString(){
return"Pantry [ingredients="+ getIngredients()+"]";
}
publicString getIngredients(){
return ingredients.toString();
}
publicvoid setIngredients(ArrayList<Ingredient> ingredients){
this.ingredients = ingredients;
}
}
project_additions/project_requirements.docx
Requirement #
Description
Task
1
The application shall allow the user to manually input recipes
· Ingredient
· Fields
· constructor(s)
· MeasuredIngredient
· Subclass of Ingredient that represents a measured quantity of a
unique ingredient in the pantry
· Extra fields for amount, measurementType, and
specialInstructions
· constructor(s)
· Recipe
· Fields
· Constructor(s)
· Display
· Prompt user for new recipe fields, new ingredient fields, save
recipe and prompt for a new recipe
· Input
2
The application shall allow the user to browse recipes
· RecipeBook
· Display
· Browse RecipeBook and view Recipe
3
The application shall allow the user to edit recipes
· RecipeBook
· removeRecipe()
· addRecipe()
4
The application shall allow the user to convert ingredient
measurements to metric
· Measurement
· Constructor(s)
5
The application shall allow the user to import pictures to
recipes
· Recipe
· importPhoto()
· Display
· Display and format picture for browsing, viewing, editing
recipes
6
The application shall allow the user to export “printer friendly”
recipes
· FacebookIntegration
· postRecipe(Recipe recipe)
· Display
· Display and Format recipe
7
The application shall allow the user to share printer friendly
recipes to social media
· FacebookIntegration
· postRecipe(Recipe recipe)
· facebookClient.publish()
· Display
· Displays confirmation
8
The application shall allow the user to create a shopping list
from recipes
· ShoppingList
· List of recipe items
· Display
· Displays recipe items needed
9
The application shall allow the user to add or remove
ingredients from their “pantry”
· Pantry
· addIngredient()
· removeIngredient()
· Display
· Display Ingredients
10
The application shall take into account the “pantry” inventory
when generating shopping lists from recipes
· ShoppingList
· Recipe chosen from list
· Pantry
· Ingredients available for recipe
· Display
· Display items needed
11
The application shall allow the user to filter recipes in the
following manners:
· By ingredient
· By diet
· By cuisine
· By meal
· RecipeBook
· recipeMethod(searchType)
· Display
· Display search results
project_additions/pseudo-code.docx
a. Input Subsystem:
(a subclass of the Display Class)
Class Input{
Takes input from the display and then sorts;
}//end class Input
b. Recipe Subsystem:
Class Recipe{
String name;
ArrayList[Ingredient] ingredientList;
ArrayList ingredientMeasurements
Enum dietType
Enum cuisineType
Enum mealType
ArrayList[String] instructions;
//Recipe Photo
Constructor(){
}
UpdateShoppingList(){
//update the shopping list with ingredients from this recipe that
aren’t in the pantry
}
ImportPhoto(String filepath){
//create photo object and associate it with this recipe
}
toString(){
//format recipe
}
addIngredient(Ingredient ingredient, Measurement
measurement){
ingredientList.add(ingredient)
ingredientMeasurements.add(measurement)
}
removeIngredient(int ingredientListIndex){
ingredientList.remove(ingredientListIndex)
ingredientMeasurements.remove(ingredientListIndex)
}
setDietType(Enum type){
dietType = type
}
setCuisineType(Enum type){
cuisineType = type
}
setMealType(Enum type){
mealType = type
}
addInstruction(String instruction){
instructions.add(instruction);
}
}//end class Recipe
c. Ingredient Subsystem:
Class Ingredient{
String name;
//Ingredient photo
String description
importPhoto(String filepath){
//create photo object and associate it with this ingredient
}
setDescription(String desc){
description = desc
}
}//end class Ingredient
d. Display Subsystem:
Class Display{
constructor(){
Create panels
Create text boxes;
}
Tabs for recipe book, pantry, and shopping list
Actionlisteners for search button
Radio buttons, fields, etc. for filtering
Menu buttons for adding recipe, ingredient
}//end class Display
e. Share to Social Media Subsystem:
//restFB http://restfb.com/
Class FacebookIntegration{
FacebookClient facebookClient //object to access facebook
data
postRecipe(Recipe recipe){
facebookClient.publish(); //publish given recipe’s toString
and photo
}
}//end class FacebookIntegration
f. Shopping List Subsystem:
Class ShoppingList{
ArrayList Ingredients;
Constructor(){
Initialize objects
}
addList(recipe){
Adds a recipe’s ingredients to the list, unless they are already in
the pantry;
}
removeList(ingredient or index){
Removes an ingredient from the list;
}
toString(){
Returns a string version of the recipes ingredients;
}
}//end class ShoppingList
g. Pantry Subsystem:
Class Pantry{
ArrayList Ingredients
Constructor(ingredient){
Initialize objects;
}// end constructor
addIngredient Method(ingredient){
If the ingredient is already in the list, then send popup saying
that there is already and ingredient;
Else add the ingredient to the pantry
}
removeIngredient Method(ingredient){
Iterate through Ingredients array list;
Remove ingredient;
Send confirmation dialogue to user;
}
toString(){
Returns the whole list of ingredients in string form;
}
}// end Pantry Class
h. Recipe Book Subsystem:
Class RecipeBook{
ArrayList Recipes;
ArrayList SearchResults
Constructor(){
Initialize object;s
}
Findrecipe method(searchtype){
If by name… then search by name;
If by cusinetype… then by cusinetype;
If by ingredients.. Then by ingredients;
Adds to an arrayList of the search results
And then returns the arraylist search results
}
addRecipe(){
Creates a recipe;
Adds to recipe list;
}
removeRecipe(){
Removes recipe from list;
}
}
project_additions/Recipe.javaproject_additions/Recipe.javaimpo
rt java.util.ArrayList;
/**
* Revisions
*
* | Revision # | Date | Description | Name |
* +------------+-------+-----------------------+---------------+
* | 1 | 7/2 | First Draft | Chris |
* +------------+-------+-----------------------+---------------+
* +------------+-------+-----------------------+---------------+
* | 2 | 7/9 | Added getters/setters | Josh |
* +------------+-------+-----------------------+---------------+
*
*/
publicclassRecipe{
privateString recipeName;
privateArrayList<MeasuredIngredient> ingredientList;
privateArrayList<Ingredient> ingredients;
privateDietType dietType;
privateCuisineType cuisineType;
privateMealType mealType;
privateArrayList<String> instructions;
publicRecipe(String name){
setRecipeName(name);
ingredientList =newArrayList<>();
setDietType(DietType.NONE);
setCuisineType(CuisineType.NONE);
setMealType(MealType.NONE);
instructions =newArrayList<>();
ingredients =newArrayList<>();
}
publicRecipe(){
}
publicvoid addIngredient(Ingredient ingredient,MeasuredIngredi
ent measurement){
ingredients.add(ingredient);
ingredientList.add(measurement);
}
publicvoid removeIngredient(int ingredientListIndex){
ingredientList.remove(ingredientListIndex);
ingredientList.remove(ingredientListIndex);
}
publicvoid addInstruction(String instruction){
instructions.add(instruction);
}
publicString getRecipeName(){
return recipeName;
}
publicvoid setRecipeName(String recipeName){
this.recipeName = recipeName;
}
publicDietType getDietType(){
return dietType;
}
publicvoid setDietType(DietType dietType){
this.dietType = dietType;
}
publicCuisineType getCuisineType(){
return cuisineType;
}
publicvoid setCuisineType(CuisineType cuisineType){
this.cuisineType = cuisineType;
}
publicMealType getMealType(){
return mealType;
}
publicvoid setMealType(MealType mealType){
this.mealType = mealType;
}
}
project_additions/RecipeBook.javaproject_additions/RecipeBoo
k.java
import java.util.ArrayList;
/**
*
*/
publicclassRecipeBook{
privateArrayList<String> recipes;
privateArrayList<String> searchResults;
publicRecipeBook(){
recipes =newArrayList<String>();
searchResults =newArrayList<String>();
}
// private String findRecipe(String searchType) {
// String result ="";
// ArrayList<String> searchResults = new ArrayList<String>();
// ArrayList<String> recipes = new ArrayList<String>();
// if (searchType.equals("name")) {
/// will be using comparator to sort by name, cuisine etc...
// }
// searchResults.add(new recipes());
//}
publicvoid addRecipe(String name,String instruction,String ingr
edients,String cusine){
//Adds to recipe list;
ArrayList<String> recipes =newArrayList<String>();
//removals will be selected via GUI
recipes.add(name);
recipes.add(instruction);
recipes.add(ingredients);
recipes.add(cusine);
}
publicvoid removeRecipe(String name,String instruction,String
ingredients,String cusine){
//Removes recipe from list;
ArrayList<String> recipes =newArrayList<String>();
//removals will be selected via GUI
recipes.remove(name);
recipes.remove(instruction);
recipes.remove(ingredients);
recipes.remove(cusine);
}
publicString[] getIngsInRecipe(String recipe){
// TODO Auto-generated method stub
returnnull;
}
publicObject getInstr(String recipe){
// TODO Auto-generated method stub
returnnull;
}
}
/*
This is the psuedo-
code from the Design document for the RecipeBook Class
ArrayList Recipes;
ArrayList SearchResults
Constructor(){
Initialize object;s
}
Findrecipe method(searchtype){
If by name… then search by name;
If by cusinetype… then by cusinetype;
If by ingredients.. Then by ingredients;
Adds to an arrayList of the search results
And then returns the arraylist search results
}
addRecipe(){
Creates a recipe;
Adds to recipe list;
}
removeRecipe(){
Removes recipe from list;
}
}
*/
project_additions/requirements_Document.txt
The focus is on requirement number 2, 3, and 11
project_additions/tasks.txt
1.)
The application shall allow the user to browse recipes:
RecipeBook -> list all
Display class ->Browse RecipeBook and view Recipe
====
2.)
The application shall allow the user to edit recipes:
RecipeBook class->removeRecipe()
RecipeBook class-> addRecipe()
====
3.)
The application shall allow the user to filter recipes in the
following manners:
• By ingredient (enum FROM Ingredient class)
• By diet (enum from DietType class)-(VEGETARIAN,
VEGAN)
• By cuisine (enum from CuisineType class) (ITALIAN,
MEXICAN, THAI, AMERICAN, JAPANESE, CHINESE,
FRENCH, VIETNAMESE, KOREAN)
• By meal ((enum from MealType class)) (BREAKFAST,
LUNCH, DINNER, SNACK, BRUNCH, DESSERT, NONE)
RecipeBook class -> recipeMethod(searchType)
Display class -> Display search results
====
the recipebook class should really be just adding to a list
creating a recipe and adding to the list
deleting a recipe from a list
and using a search target to search a list
using loops to just iterate through
and find a recipe by a certain tag such as name
project/CuisineType.javaproject/CuisineType.javapublic enum
CuisineType{
ITALIAN, MEXICAN, THAI, AMERICAN, JAPANESE, CHI
NESE, FRENCH, VIETNAMESE,
KOREAN, NONE
}
project/Design_Doc.docx
Display Class
Display
Constructor:
Create panels
Create textBoxes
Actionlisteners
for seach
button
Menu Button
for adding
recipe
Input Class
(sub-class of
Display)
Sorts Input
from Display
Class
ShoppingList
Class
ArrayList:
Recipes
ShoppingList
Constructor:
Initialization of
Objects
addList(recipe)
removeList(recipe)
toString():
formatting
Adds to recipe list
Removes from List
1
Display
Constructor:
Create panels
Create textBoxes
Pantry Class
Pantry Constructor:
Initialization of
Objects
addIngredient
Method(ingredient)
removeIngredient
Method(ingredient)
toString():
formatting
ArrayList:
Ingredients
IF: on the list
Send notification
prompt
Else: not on the
list
Add to the List
Remove from
List
Send notification
prompt
1
Recipe Class
String: Name
ArrayList:
ingredientList
ArrayList:
instructions
Recipe Constructor:
(name, Temperature,
instructions)
ArrayList:
ingredientMeasurements
Enum:
dietType
Enum:
cuisineType
Enum:
mealType
UpdateShoppingList()
Items not in pantry
ImportPhoto(String
filepath)
toString(): formatting
addIngredient(Ingredie
nt ingredient, int
measurement)
removeIngredient(int
ingredientListIndex)
setDietType(Enum
type)
setCuisineType(Enum
type)
addInstruction(String
instruction)
setMealType(Enum
type)
1
RecipeBook Class
RecipeBook
Constructor:
Initialization of
Objects
addRecipe()
removeRecipe()
ArrayList:
Recipes
ArrayList:
SearchResults
Recipe Creation
Removes from
List
Adds to List
Findrecipe
method
(searchtype)
IF by name /
cusineType /
ingredients
THEN by name /
cusineType /
ingredients
1
Ingredient Class
String: Name
String:
Description
importPhoto(String
filepath)
Create and
associate photo
with ingredient
setDecription(String
desc):
Description = desc
FacebookIntegration
Object:
FacebookClient
facebookClient
postRecipe(Recipe
recipe)
facebookClient.publish();
1
project/DietType.javaproject/DietType.javapublic enum DietTy
pe{
VEGETARIAN, VEGAN, NONE
}
project/Display.javaproject/Display.javaimport javax.swing.JFra
me;
import java.awt.CardLayout;
import javax.swing.JPanel;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;
import java.awt.event.ActionEvent;
import javax.swing.JTextField;
import javax.swing.JLabel;
import java.awt.GridLayout;
publicclassDisplay{
privateJFrame frame;
privateJTextField txtIngredient;
privateRecipe recipe =newRecipe();
privateRecipeBook book =newRecipeBook();
/**
* Launch the application. test
*/
publicstaticvoid main(String[] args){
//TODO:Hardcoding ingredients, These will be replaced by the i
nput from the screen
Display display =newDisplay();
display.frame.setVisible(true);
}
/**
* Create the application.
*/
publicDisplay(){
initialize();
}
/**
* Initialize the contents of the frame.
*/
privatevoid initialize(){
frame =newJFrame();
frame.setBounds(100,100,450,300);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOS
E);
frame.getContentPane().setLayout(newCardLayout(0,0));
frame.setTitle("Welcome to your pantry!");
finalJPanel panelInitialScreen =newJPanel();
panelInitialScreen.setLayout(null);
panelInitialScreen.setVisible(true);
finalJPanel panelRecipeChoicesScreen =newJPanel();
panelRecipeChoicesScreen.setLayout(null);
panelRecipeChoicesScreen.setVisible(false);
finalJPanel panelRecipeInstructionsScreen =newJPanel();
frame.getContentPane().add(panelRecipeInstructionsScree
n,"name_293133281550638"); panelRecipeInstructionsScree
n.setLayout(null);
panelRecipeInstructionsScreen.setVisible(false);
finalJPanel panelGroceryListScreen =newJPanel();
panelGroceryListScreen.setLayout(null);
JButton btnGetRecipes =newJButton("Get Recipes");
btnGetRecipes.addActionListener(newActionListener(){
publicvoid actionPerformed(ActionEvent e){
if(myPantry.getIngredients().isEmpty()){
}else{
panelRecipeChoicesScreen.setVisible(true);
panelRecipeChoicesScreen.setLayout(newGridLay
out(0,1));
//Get the recipes that contain myPantry's ingredients
Set<String> recipsToDisplay=newHashSet<String>();
for(String ingredient:myPantry.getIngredients()){
for(String recipe:myCookbook.getRecipsFromIng(ingredient)){
recipsToDisplay.add(recipe);
}
}
//Add the buttons to display
JButton[] buttons=newJButton[recipsToDisplay.size()];
int index=0;
for(finalString recipe:recipsToDisplay){
//Make an array of buttons so you can add action listeners to eac
h one to
//display the recipe in the recipe screen JPanel, or the grocery li
st if
//the pantry is missing some ingredients
buttons[index]=newJButton(recipe);
buttons[index].addActionListener(newActionLi
stener(){
publicvoid actionPerformed(ActionEvent e){
// check if you have everything the recipe asks for and show
//the recipe if so, otherwise show the grocery list
String[] ingsInRecipe=myCookbook.getIngsInRecipe(recipe);
boolean gotAllIngs=true;
ArrayList<String> groceryList=newArrayList<String>();
for(String ing:ingsInRecipe){
if(!myPantry.getIngredients().contains(ing)){
gotAllIngs=false;
groceryList.add(ing);
}
}
for(String instruction:myCookbook.getInstr(recipe)){
panelRecipeInstructionsScreen.add(new
JLabel(instruction));
}
panelRecipeInstructionsScreen.setLayout(
newGridLayout(0,1));
JButton doneCookingButton=newJButton("Done Cooking");
panelRecipeInstructionsScreen.add(doneC
ookingButton);
doneCookingButton.addActionListener(ne
wActionListener(){
@Override
publicvoid actionPerformed(ActionEvent e){
frame.dispose();
}
});
if(gotAllIngs){
//Display recipe
panelRecipeInstructionsScreen.setVisib
le(true);
frame.setTitle("Cook Away!");
panelRecipeChoicesScreen.setVisible(f
alse);
}
else{
//Display grocery list
panelGroceryListScreen.setLayout(new
GridLayout(0,1));
JLabel lblWeDisplayThe =newJLabel("You're missing these ing
redients!");
panelGroceryListScreen.add(lblWeDisp
layThe);
for(String ing:groceryList){
javax.swing.JCheckBox box=new jav
ax.swing.JCheckBox();
box.setText(ing);
panelGroceryListScreen.add(box);
}
JButton nextButton=newJButton("next");
panelGroceryListScreen.add(nextButton
);
nextButton.addActionListener(newActi
onListener(){
@Override
publicvoid actionPerformed(ActionEvent e){
//Display the recipe!
//Add the right recipe to the screen first
panelRecipeInstructionsScreen.set
Visible(true);
panelGroceryListScreen.setVisibl
e(false);
frame.setTitle("Cook Away!");
}
});
panelGroceryListScreen.setVisible(true
);
panelRecipeChoicesScreen.setVisible(f
alse);
frame.setTitle("Grocery List");
}
}
});
panelRecipeChoicesScreen.add(buttons[index]);
index++;
}
panelInitialScreen.setVisible(false);
frame.setTitle("Recipe Suggestions");
}
}
});
btnGetRecipes.setBounds(138,182,117,29);
panelInitialScreen.add(btnGetRecipes);
txtIngredient =newJTextField();
txtIngredient.setBounds(112,4,130,28);
txtIngredient.setText("Ingredient");
panelInitialScreen.add(txtIngredient);
txtIngredient.setColumns(10);
JButton btnAddIngButton =newJButton("Enter");
btnAddIngButton.addActionListener(newActionListener(){
publicvoid actionPerformed(ActionEvent e){
//TODO
System.out.println(txtIngredient.getText());
myPantry.addIngredient(txtIngredient.getText());
}
});
btnAddIngButton.setBounds(254,5,76,29);
panelInitialScreen.add(btnAddIngButton);
}
}
project/Ingredient.javaproject/Ingredient.javaimport java.awt.im
age.BufferedImage;
publicclassIngredient{
publicString ingredientName;
publicBufferedImage photo;
publicString description;
publicIngredient(String name,String desc){
ingredientName = name;
photo =null;
description = desc;
}
}
project/MealType.javaproject/MealType.javapublic enum MealT
ype{
BREAKFAST, LUNCH, DINNER, SNACK, BRUNCH, DESS
ERT, NONE
}
project/MeasuredIngredient.javaproject/MeasuredIngredient.jav
apublicclassMeasuredIngredientextendsIngredient{
publicMeasurementType measurementType;
publicfloat measurementAmount;
publicString specialInstructions;
publicMeasuredIngredient(Ingredient ingredient,MeasurementT
ype type,
float amount,String instructions){
super(ingredient.ingredientName, ingredient.description);
measurementType = type;
measurementAmount = amount;
specialInstructions = instructions;
}
}
project/MeasurementType.javaproject/MeasurementType.javaim
port java.util.EnumSet;
public enum MeasurementType{
CUP, TEASPOON, TABLESPOON, FLUID_OUNCE, MILLI
LITER, LITER, DECILITER,
POUND, OUNCE, MILIGRAM, GRAM, KILOGRAM;
publicstaticEnumSet<MeasurementType> volume =EnumSet.of(
CUP, TEASPOON,
TABLESPOON, FLUID_OUNCE, MILLILITER, LITER
, DECILITER);
publicstaticEnumSet<MeasurementType> mass =EnumSet.of(PO
UND, OUNCE,
MILIGRAM, GRAM, KILOGRAM);
}
project/project_requirements.docx
Requirement #
Description
Task
1
The application shall allow the user to manually input recipes
· Ingredient
· Fields
· constructor(s)
· MeasuredIngredient
· Subclass of Ingredient that represents a measured quantity of a
unique ingredient in the pantry
· Extra fields for amount, measurementType, and
specialInstructions
· constructor(s)
· Recipe
· Fields
· Constructor(s)
· Display
· Prompt user for new recipe fields, new ingredient fields, save
recipe and prompt for a new recipe
· Input
2
The application shall allow the user to browse recipes
· RecipeBook
· Display
· Browse RecipeBook and view Recipe
3
The application shall allow the user to edit recipes
· RecipeBook
· removeRecipe()
· addRecipe()
4
The application shall allow the user to convert ingredient
measurements to metric
· Measurement
· Constructor(s)
5
The application shall allow the user to import pictures to
recipes
· Recipe
· importPhoto()
· Display
· Display and format picture for browsing, viewing, editing
recipes
6
The application shall allow the user to export “printer friendly”
recipes
· FacebookIntegration
· postRecipe(Recipe recipe)
· Display
· Display and Format recipe
7
The application shall allow the user to share printer friendly
recipes to social media
· FacebookIntegration
· postRecipe(Recipe recipe)
· facebookClient.publish()
· Display
· Displays confirmation
8
The application shall allow the user to create a shopping list
from recipes
· ShoppingList
· List of recipe items
· Display
· Displays recipe items needed
9
The application shall allow the user to add or remove
ingredients from their “pantry”
· Pantry
· addIngredient()
· removeIngredient()
· Display
· Display Ingredients
10
The application shall take into account the “pantry” inventory
when generating shopping lists from recipes
· ShoppingList
· Recipe chosen from list
· Pantry
· Ingredients available for recipe
· Display
· Display items needed
11
The application shall allow the user to filter recipes in the
following manners:
· By ingredient
· By diet
· By cuisine
· By meal
· RecipeBook
· recipeMethod(searchType)
· Display
· Display search results
project/pseudo-code.docx
a. Input Subsystem:
(a subclass of the Display Class)
Class Input{
Takes input from the display and then sorts;
}//end class Input
b. Recipe Subsystem:
Class Recipe{
String name;
ArrayList[Ingredient] ingredientList;
ArrayList ingredientMeasurements
Enum dietType
Enum cuisineType
Enum mealType
ArrayList[String] instructions;
//Recipe Photo
Constructor(){
}
UpdateShoppingList(){
//update the shopping list with ingredients from this recipe that
aren’t in the pantry
}
ImportPhoto(String filepath){
//create photo object and associate it with this recipe
}
toString(){
//format recipe
}
addIngredient(Ingredient ingredient, Measurement
measurement){
ingredientList.add(ingredient)
ingredientMeasurements.add(measurement)
}
removeIngredient(int ingredientListIndex){
ingredientList.remove(ingredientListIndex)
ingredientMeasurements.remove(ingredientListIndex)
}
setDietType(Enum type){
dietType = type
}
setCuisineType(Enum type){
cuisineType = type
}
setMealType(Enum type){
mealType = type
}
addInstruction(String instruction){
instructions.add(instruction);
}
}//end class Recipe
c. Ingredient Subsystem:
Class Ingredient{
String name;
//Ingredient photo
String description
importPhoto(String filepath){
//create photo object and associate it with this ingredient
}
setDescription(String desc){
description = desc
}
}//end class Ingredient
d. Display Subsystem:
Class Display{
constructor(){
Create panels
Create text boxes;
}
Tabs for recipe book, pantry, and shopping list
Actionlisteners for search button
Radio buttons, fields, etc. for filtering
Menu buttons for adding recipe, ingredient
}//end class Display
e. Share to Social Media Subsystem:
//restFB http://restfb.com/
Class FacebookIntegration{
FacebookClient facebookClient //object to access facebook
data
postRecipe(Recipe recipe){
facebookClient.publish(); //publish given recipe’s toString
and photo
}
}//end class FacebookIntegration
f. Shopping List Subsystem:
Class ShoppingList{
ArrayList Ingredients;
Constructor(){
Initialize objects
}
addList(recipe){
Adds a recipe’s ingredients to the list, unless they are already in
the pantry;
}
removeList(ingredient or index){
Removes an ingredient from the list;
}
toString(){
Returns a string version of the recipes ingredients;
}
}//end class ShoppingList
g. Pantry Subsystem:
Class Pantry{
ArrayList Ingredients
Constructor(ingredient){
Initialize objects;
}// end constructor
addIngredient Method(ingredient){
If the ingredient is already in the list, then send popup saying
that there is already and ingredient;
Else add the ingredient to the pantry
}
removeIngredient Method(ingredient){
Iterate through Ingredients array list;
Remove ingredient;
Send confirmation dialogue to user;
}
toString(){
Returns the whole list of ingredients in string form;
}
}// end Pantry Class
h. Recipe Book Subsystem:
Class RecipeBook{
ArrayList Recipes;
ArrayList SearchResults
Constructor(){
Initialize object;s
}
Findrecipe method(searchtype){
If by name… then search by name;
If by cusinetype… then by cusinetype;
If by ingredients.. Then by ingredients;
Adds to an arrayList of the search results
And then returns the arraylist search results
}
addRecipe(){
Creates a recipe;
Adds to recipe list;
}
removeRecipe(){
Removes recipe from list;
}
}
project/Recipe.javaproject/Recipe.javaimport java.util.ArrayList
;
publicclassRecipe{
privateString recipeName;
privateArrayList<MeasuredIngredient> ingredientList;
privateDietType dietType;
privateCuisineType cuisineType;
privateMealType mealType;
privateArrayList<String> instructions;
publicRecipe(String name){
recipeName = name;
ingredientList =newArrayList<>();
dietType =DietType.NONE;
cuisineType =CuisineType.NONE;
mealType =MealType.NONE;
instructions =newArrayList<>();
}
}
project/RecipeBook.javaproject/RecipeBook.java/*
* To change this license header, choose License Headers in Pro
ject Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package recipebook;
import java.util.ArrayList;
import java.util.Scanner;
/**
* Revisions
*
* | Revision # | Date | Description | Name |
* +------------+-------+-----------------------+---------------+
* | 1 | 7/2 | First Draft | Joshua |
* +------------+-------+-----------------------+---------------+
*
*/
publicclassRecipeBook{
privateScanner sc =newScanner(System.in);//for testing
publicRecipeBook(){
ArrayList<String> recipes =newArrayList<String>();
ArrayList<String> searchResults =newArrayList<String>();
Scanner sc =newScanner(System.in);//for testing
}
// private String findRecipe(String searchType) {
// String result ="";
// ArrayList<String> searchResults = new ArrayList<String>();
// ArrayList<String> recipes = new ArrayList<String>();
// if (searchType.equals("name")) {
/// will be using comparator to sort by name, cuisine etc...
// }
// searchResults.add(new recipes());
//}
publicvoid addRecipe(String name,String instruction,String ingr
edients,String cusine){
//Adds to recipe list;
ArrayList<String> recipes =newArrayList<String>();
//removals will be selected via GUI
recipes.add(name);
recipes.add(instruction);
recipes.add(ingredients);
recipes.add(cusine);
}
publicvoid removeRecipe(String name,String instruction,String
ingredients,String cusine){
//Removes recipe from list;
ArrayList<String> recipes =newArrayList<String>();
//removals will be selected via GUI
recipes.remove(name);
recipes.remove(instruction);
recipes.remove(ingredients);
recipes.remove(cusine);
}
publicstaticvoid main(String[] args){
// TODO code application logic here
}
}
/*
This is the psuedo-
code from the Design document for the RecipeBook Class
ArrayList Recipes;
ArrayList SearchResults
Constructor(){
Initialize object;s
}
Findrecipe method(searchtype){
If by name… then search by name;
If by cusinetype… then by cusinetype;
If by ingredients.. Then by ingredients;
Adds to an arrayList of the search results
And then returns the arraylist search results
}
addRecipe(){
Creates a recipe;
Adds to recipe list;
}
removeRecipe(){
Removes recipe from list;
}
}
*/
project/requirements_Document.txt
The focus is on requirement number 2, 3, and 11
project/tasks.txt
1.)
The application shall allow the user to browse recipes:
RecipeBook -> list all
Display class ->Browse RecipeBook and view Recipe
====
2.)
The application shall allow the user to edit recipes:
RecipeBook class->removeRecipe()
RecipeBook class-> addRecipe()
====
3.)
The application shall allow the user to filter recipes in the
following manners:
• By ingredient (enum FROM Ingredient class)
• By diet (enum from DietType class)-(VEGETARIAN,
VEGAN)
• By cuisine (enum from CuisineType class) (ITALIAN,
MEXICAN, THAI, AMERICAN, JAPANESE, CHINESE,
FRENCH, VIETNAMESE, KOREAN)
• By meal ((enum from MealType class)) (BREAKFAST,
LUNCH, DINNER, SNACK, BRUNCH, DESSERT, NONE)
RecipeBook class -> recipeMethod(searchType)
Display class -> Display search results
project_additionsCuisineType.javaproject_additionsCuisineType..docx

More Related Content

DOCX
1 PROBLEM You are to design and implement a Menu class.docx
PDF
Hello everyone,Im actually working on a fast food order program..pdf
PPTX
Java me lab2-slides (gui programming)
PDF
Hello everyone,Im working on my fast food order project program..pdf
PDF
Extracting ui Design - part 5 - transcript.pdf
PPSX
Aula 6 - 08/05 (Menu)
PPTX
Vs c# lecture3
PPTX
Vp lecture 6 ararat
1 PROBLEM You are to design and implement a Menu class.docx
Hello everyone,Im actually working on a fast food order program..pdf
Java me lab2-slides (gui programming)
Hello everyone,Im working on my fast food order project program..pdf
Extracting ui Design - part 5 - transcript.pdf
Aula 6 - 08/05 (Menu)
Vs c# lecture3
Vp lecture 6 ararat

More from briancrawford30935 (20)

DOCX
You have collected the following documents (unstructured) and pl.docx
DOCX
You have been working as a technology associate the information .docx
DOCX
You have chosen to join WHO. They are particularly interested in.docx
DOCX
You have been tasked to present at a town hall meeting in your local.docx
DOCX
You have been tasked as the health care administrator of a major hos.docx
DOCX
You have been tasked to devise a program to address the needs of.docx
DOCX
You have been successful in your application for the position be.docx
DOCX
You have been hired as a project management consultant by compan.docx
DOCX
You have been hired to manage a particular aspect of the new ad.docx
DOCX
You have been hired by Red Didgeridoo Technologies. They know th.docx
DOCX
You have been hired by TMI to design an application using shell scri.docx
DOCX
You have been hired as the CSO (Chief Security Officer) for an org.docx
DOCX
You have been hired to evaluate the volcanic hazards associated .docx
DOCX
You have been hired as an assistant to the public health officer for.docx
DOCX
You have been engaged to develop a special calculator program. T.docx
DOCX
You have now delivered the project to your customer ahead of schedul.docx
DOCX
You have now delivered the project to your customer. The project was.docx
DOCX
You have now experienced the work of various scholars, artists and m.docx
DOCX
You have learned that Mr. Moore does not drink alcohol in the mornin.docx
DOCX
You have been hired by a large hospitality firm (e.g., Marriot.docx
You have collected the following documents (unstructured) and pl.docx
You have been working as a technology associate the information .docx
You have chosen to join WHO. They are particularly interested in.docx
You have been tasked to present at a town hall meeting in your local.docx
You have been tasked as the health care administrator of a major hos.docx
You have been tasked to devise a program to address the needs of.docx
You have been successful in your application for the position be.docx
You have been hired as a project management consultant by compan.docx
You have been hired to manage a particular aspect of the new ad.docx
You have been hired by Red Didgeridoo Technologies. They know th.docx
You have been hired by TMI to design an application using shell scri.docx
You have been hired as the CSO (Chief Security Officer) for an org.docx
You have been hired to evaluate the volcanic hazards associated .docx
You have been hired as an assistant to the public health officer for.docx
You have been engaged to develop a special calculator program. T.docx
You have now delivered the project to your customer ahead of schedul.docx
You have now delivered the project to your customer. The project was.docx
You have now experienced the work of various scholars, artists and m.docx
You have learned that Mr. Moore does not drink alcohol in the mornin.docx
You have been hired by a large hospitality firm (e.g., Marriot.docx
Ad

Recently uploaded (20)

PDF
Complications of Minimal Access Surgery at WLH
PDF
RMMM.pdf make it easy to upload and study
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PPTX
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
PPTX
Cell Types and Its function , kingdom of life
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
A systematic review of self-coping strategies used by university students to ...
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
Trump Administration's workforce development strategy
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PPTX
Pharma ospi slides which help in ospi learning
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
PPTX
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
PPTX
Orientation - ARALprogram of Deped to the Parents.pptx
PPTX
202450812 BayCHI UCSC-SV 20250812 v17.pptx
Complications of Minimal Access Surgery at WLH
RMMM.pdf make it easy to upload and study
2.FourierTransform-ShortQuestionswithAnswers.pdf
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
Cell Types and Its function , kingdom of life
Supply Chain Operations Speaking Notes -ICLT Program
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
human mycosis Human fungal infections are called human mycosis..pptx
A systematic review of self-coping strategies used by university students to ...
Final Presentation General Medicine 03-08-2024.pptx
Trump Administration's workforce development strategy
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Pharma ospi slides which help in ospi learning
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
O5-L3 Freight Transport Ops (International) V1.pdf
Abdominal Access Techniques with Prof. Dr. R K Mishra
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
Orientation - ARALprogram of Deped to the Parents.pptx
202450812 BayCHI UCSC-SV 20250812 v17.pptx
Ad

project_additionsCuisineType.javaproject_additionsCuisineType..docx

  • 1. project_additions/CuisineType.javaproject_additions/CuisineTy pe.javapublic enum CuisineType{ ITALIAN, MEXICAN, THAI, AMERICAN, JAPANESE, CHI NESE, FRENCH, VIETNAMESE, KOREAN, NONE } project_additions/Design_Doc.docx Display Class Display Constructor: Create panels Create textBoxes
  • 2. Actionlisteners for seach button Menu Button for adding recipe Input Class (sub-class of Display) Sorts Input from Display Class ShoppingList Class ArrayList: Recipes ShoppingList Constructor: Initialization of Objects addList(recipe) removeList(recipe) toString(): formatting Adds to recipe list Removes from List 1 Display Constructor: Create panels Create textBoxes Pantry Class Pantry Constructor:
  • 3. Initialization of Objects addIngredient Method(ingredient) removeIngredient Method(ingredient) toString(): formatting ArrayList: Ingredients IF: on the list Send notification prompt Else: not on the list Add to the List Remove from List Send notification prompt 1 Recipe Class String: Name ArrayList: ingredientList ArrayList: instructions Recipe Constructor: (name, Temperature, instructions) ArrayList: ingredientMeasurements Enum: dietType Enum:
  • 4. cuisineType Enum: mealType UpdateShoppingList() Items not in pantry ImportPhoto(String filepath) toString(): formatting addIngredient(Ingredie nt ingredient, int measurement) removeIngredient(int ingredientListIndex) setDietType(Enum type) setCuisineType(Enum type) addInstruction(String instruction) setMealType(Enum type) 1 RecipeBook Class RecipeBook Constructor: Initialization of Objects addRecipe() removeRecipe() ArrayList: Recipes ArrayList: SearchResults Recipe Creation Removes from
  • 5. List Adds to List Findrecipe method (searchtype) IF by name / cusineType / ingredients THEN by name / cusineType / ingredients 1 Ingredient Class String: Name String: Description importPhoto(String filepath) Create and associate photo with ingredient setDecription(String desc): Description = desc FacebookIntegration Object: FacebookClient facebookClient postRecipe(Recipe recipe) facebookClient.publish(); 1 project_additions/DietType.javaproject_additions/DietType.java
  • 6. public enum DietType{ VEGETARIAN, VEGAN, NONE } project_additions/Display.javaproject_additions/Display.javaim port java.awt.BorderLayout; import java.awt.GridBagLayout; import java.awt.GridLayout; import java.io.File; import javax.swing.Box; import javax.swing.DefaultListModel; import javax.swing.DefaultListSelectionModel; import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JFileChooser; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JList; importstatic javax.swing.JList.VERTICAL; import javax.swing.JMenu; import javax.swing.JMenuBar; import javax.swing.JMenuItem; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JSplitPane; import javax.swing.JTabbedPane; import javax.swing.JTextArea; import javax.swing.JTextField; // Date: July 6, 2017 // Authors: // Purpose: Create a recipe manager
  • 7. /** * */ publicclassDisplayextendsJFrame{ //global variables staticfinallong serialVerisionUID =123L; JTextArea jta =newJTextArea(); staticDefaultListModel listModel, pantryListModel, shoppingLi stModel ; JMenuBar menuBar; JMenu menu, submenu; JMenuItem menuItem; JTextField jtf =newJTextField(20); JButton searchButton =newJButton("Search"); JComboBox<String> jcb =newJComboBox<String>(); JList list, pantryList, shoppingList; File photoFile =null; finalJFileChooser fc =newJFileChooser(); JTabbedPane tp =newJTabbedPane(); publicstaticvoid main(String[] args){ Display gui =newDisplay(); }// end main method //constructor publicDisplay(){ //setting basic jframe functions setTitle("Recipe Manager"); setSize(900,600); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setVisible(true); setLocationRelativeTo(null); //setting text area for recipe jta.setEditable(false); JScrollPane jsp =newJScrollPane(jta);
  • 8. //setting recipe list pane listModel =newDefaultListModel(); list =newJList(listModel); list.setLayoutOrientation(VERTICAL); list.setSelectionMode(DefaultListSelectionModel.SINGL E_SELECTION); JScrollPane listpane =newJScrollPane(list); list.getSelectionModel().addListSelectionListener(e - > listContents()); //setting pantry list pane pantryListModel =newDefaultListModel(); pantryList =newJList(pantryListModel); pantryList.setLayoutOrientation(VERTICAL); pantryList.setSelectionMode(DefaultListSelectionModel. SINGLE_SELECTION); JScrollPane pantryListPane =newJScrollPane(pantryList); //setting shopping list pane shoppingListModel =newDefaultListModel(); shoppingList =newJList(pantryListModel); shoppingList.setLayoutOrientation(VERTICAL); shoppingList.setSelectionMode(DefaultListSelectionMod el.SINGLE_SELECTION); JScrollPane shoppingListPane =newJScrollPane(shoppingList); //setting menu SetMenuBar(); add(menuBar,BorderLayout.PAGE_START); //setting the split panes JSplitPane splitpane =newJSplitPane(JSplitPane.HORIZONTAL _SPLIT); splitpane.setRightComponent(jsp);
  • 9. splitpane.setLeftComponent(listpane); // setting tabbed panes tp.add("recipes", splitpane); tp.add("pantry", pantryListPane); tp.add("shopping", shoppingListPane); add(tp); // add(splitpane,BorderLayout.CENTER); validate();// validates all components }// end display constructor //class for setting menu bar privatevoidSetMenuBar(){ menuBar =newJMenuBar(); //Recipe Menu menu =newJMenu("Recipe"); menuBar.add(menu); menuItem =newJMenuItem("add recipe"); menuItem.addActionListener(e -> recipeForm()); menu.add(menuItem); menuItem =newJMenuItem("edit recipe"); menuItem.addActionListener(e -> editForm()); menu.add(menuItem); menuItem =newJMenuItem("remove selected recipe"); menuItem.addActionListener(e -> editForm()); menu.add(menuItem); //Pantry Menu //Pantry Menu menu =newJMenu("Pantry"); menuBar.add(menu);
  • 10. menuItem =newJMenuItem("Add to Pantry"); menuItem.addActionListener(e ->Input.addToPantry()); menu.add(menuItem); menuItem =newJMenuItem("Remove from Pantry"); menu.add(menuItem); //Shopping List Menu menu =newJMenu("Shopping"); menuBar.add(menu); menuItem =newJMenuItem("Add selected recipe to list"); menu.add(menuItem); //Export Menu menu =newJMenu("Export"); menuBar.add(menu); menuItem =newJMenuItem("Print"); menu.add(menuItem); menuItem =newJMenuItem("Social Media"); menu.add(menuItem); // adding to the right menuBar.add(Box.createHorizontalGlue()); menuBar.add(searchBar()); }// end setmenubar method privateJPanel searchBar(){//still working on this JPanel jp =newJPanel(); jcb.addItem ("Name"); jcb.addItem ("Type"); jcb.addItem ("Ingredients");
  • 11. jp.add(jtf); jp.add(jcb); jp.add(searchButton); searchButton.addActionListener(e - >Input.searchRecipe()); return jp; }// end searchBar method protectedvoid recipeForm(){ // method for adding recipe JFrame addFrame =newJFrame("Add Recipe"); JTextField recipeName =newJTextField(20); JTextField ingredients =newJTextField(); JTextArea instructions =newJTextArea(); JScrollPane scrollpane =newJScrollPane(instructions); JButton addPicture =newJButton("Add Picture"); addFrame.setLocationRelativeTo(null); JPanel form =newJPanel(newGridLayout(0,1)); form.add(newJLabel("Recipe Name")); form.add(recipeName); form.add(newJLabel("Ingredients delimited by ';'")); form.add(ingredients); form.add(newJLabel("Instructions")); form.add(scrollpane); form.add(addPicture); addPicture.addActionListener(e - > addPhoto(addFrame)); // JPanel Button Panel = new JPanel(); JPanel buttons =newJPanel();
  • 12. JButton submit =newJButton("Add"); submit.addActionListener(e - >Input.addRecipe(recipeName.getText(), ingredients.getText(), instructions.getText(), addFrame) ); // submit.addActionListener(e -> ); JButton cancel =newJButton("Cancel"); cancel.addActionListener(e -> addFrame.dispose()); buttons.add(submit); buttons.add(cancel); form.add(buttons); addFrame.add(form); addFrame.pack(); addFrame.setSize(500,500); addFrame.setVisible(true); }//end method addRecipe privatevoid addPhoto(JFrame form){ int returnVal = fc.showOpenDialog(form); if(returnVal ==JFileChooser.APPROVE_OPTION){ photoFile = fc.getSelectedFile(); } } protectedvoid editForm(){ //Object selected = listModel.getElementAt(list.getSelectedInde x()); JFrame editFrame =newJFrame("Edit Recipe"); JTextField recipeName =newJTextField(20); JTextField ingredients =newJTextField(); JTextArea instructions =newJTextArea(); JScrollPane scrollpane =newJScrollPane(instructions); JButton addPicture =newJButton("Add Picture"); editFrame.setLocationRelativeTo(null); JPanel form =newJPanel(newGridLayout(0,1));
  • 13. form.add(newJLabel("Recipe Name")); form.add(recipeName); form.add(newJLabel("Ingredients delimited by ';'")); form.add(ingredients); form.add(newJLabel("Instructions")); form.add(scrollpane); // JPanel Button Panel = new JPanel(); form.add(addPicture); addPicture.addActionListener(e - > addPhoto(editFrame)); JPanel buttons =newJPanel(); JButton submit =newJButton("Add"); submit.addActionListener(e - >Input.addRecipe(recipeName.getText(), ingredients.getText(), instructions.getText(), editFrame) ); // submit.addActionListener(e -> ); JButton cancel =newJButton("Cancel"); cancel.addActionListener(e -> editFrame.dispose()); buttons.add(submit); buttons.add(cancel); form.add(buttons); editFrame.add(form); editFrame.pack(); editFrame.setSize(500,500); editFrame.setVisible(true); }// end editForm method protectedvoid removeRecipe(){ } protectedvoid listContents(){
  • 14. //lists the contents of the recipe/pantry list/ shopping list } protectedvoid addToShoppingList(){ } // defines the actions for the components staticclassInput{ protectedstaticvoid searchRecipe(){ // method for searching Recipe /* Here a method should be added for searching the recipe. .. soemthing like Recipe = search(jcb.getSelected.toString(), jtf.getText() ) ^ that method will return a recipe, so I can add the resul t later */ //return recipe //set textbox }// end method searchRecipe protectedstaticvoid addRecipe(String name,String ingredients,St ring instruction,JFrame addFrame){ //create a recipe object from this //photoFile is global
  • 15. //add object to the list model... be sure to have a toString metho d with the recipes name listModel.addElement("test"); addFrame.dispose(); }// end addRecipe method protectedstaticvoid editRecipe(){ }//end editRecipe form protectedstaticvoid removeRecipe(){ //removing the selected recope from the list } protectedstaticvoid addToPantry(){ String ingredients=JOptionPane.showInputDialog("Add ingredie nts delimited by ';'"); //takes a string of ingredients and then addes each as an ingredie nt } }// end class input }// end class Display project_additions/Ingredient.javaproject_additions/Ingredient.ja vaimport java.awt.image.BufferedImage;
  • 16. /** * Revisions * * | Revision # | Date | Description | Name | * +------------+-------+-----------------------+---------------+ * | 1 | 7/2 | First Draft | Chris | * +------------+-------+-----------------------+---------------+ * | 1 | 7/9 | Added toString() | Josh | * +------------+-------+-----------------------+---------------+ * */ publicclassIngredient{ publicString ingredientName; publicBufferedImage photo; publicString description; publicIngredient(String name,String desc){ ingredientName = name; photo =null; description = desc; } @Override publicString toString(){ return"Ingredient [ingredientName="+ ingredientName +", phot o="+ photo +", description="+ description +"]"; } } project_additions/MealType.javaproject_additions/MealType.ja vapublic enum MealType{
  • 17. BREAKFAST, LUNCH, DINNER, SNACK, BRUNCH, DESS ERT, NONE } project_additions/MeasuredIngredient.javaproject_additions/Me asuredIngredient.javapublicclassMeasuredIngredientextendsIngr edient{ publicMeasurementType measurementType; publicfloat measurementAmount; publicString specialInstructions; publicMeasuredIngredient(Ingredient ingredient,MeasurementT ype type, float amount,String instructions){ super(ingredient.ingredientName, ingredient.description); measurementType = type; measurementAmount = amount; specialInstructions = instructions; } } project_additions/MeasurementType.javaproject_additions/Meas urementType.javaimport java.util.EnumSet; public enum MeasurementType{ CUP, TEASPOON, TABLESPOON, FLUID_OUNCE, MILLI LITER, LITER, DECILITER, POUND, OUNCE, MILIGRAM, GRAM, KILOGRAM; publicstaticEnumSet<MeasurementType> volume =EnumSet.of( CUP, TEASPOON, TABLESPOON, FLUID_OUNCE, MILLILITER, LITER , DECILITER);
  • 18. publicstaticEnumSet<MeasurementType> mass =EnumSet.of(PO UND, OUNCE, MILIGRAM, GRAM, KILOGRAM); } project_additions/Pantry.javaproject_additions/Pantry.javaimpor t java.util.ArrayList; /** * Revisions * * | Revision # | Date | Description | Name | * +------------+-------+-----------------------+---------------+ * | 1 | 7/9 | First Draft | Josh | * +------------+-------+-----------------------+---------------+ * */ publicclassPantry{ privateArrayList<Ingredient> ingredients; publicPantry(Ingredient ingredient){ ingredients =newArrayList<>(); ingredients.add(ingredient); } publicPantry(){ } publicvoid addIngredient(Ingredient ingredient){ if(ingredients.contains(ingredient)){ System.out.println("Don't Add!"); }else{ ingredients.add(ingredient);
  • 19. } } publicString removeIngredient(Ingredient ingredient){ if(ingredients.contains(ingredient)){ ingredients.remove(ingredient); return"Removed"; } return"Not found"; } @Override publicString toString(){ return"Pantry [ingredients="+ getIngredients()+"]"; } publicString getIngredients(){ return ingredients.toString(); } publicvoid setIngredients(ArrayList<Ingredient> ingredients){ this.ingredients = ingredients; } } project_additions/project_requirements.docx Requirement # Description Task 1 The application shall allow the user to manually input recipes
  • 20. · Ingredient · Fields · constructor(s) · MeasuredIngredient · Subclass of Ingredient that represents a measured quantity of a unique ingredient in the pantry · Extra fields for amount, measurementType, and specialInstructions · constructor(s) · Recipe · Fields · Constructor(s) · Display · Prompt user for new recipe fields, new ingredient fields, save recipe and prompt for a new recipe · Input 2 The application shall allow the user to browse recipes · RecipeBook · Display · Browse RecipeBook and view Recipe 3 The application shall allow the user to edit recipes · RecipeBook · removeRecipe() · addRecipe() 4 The application shall allow the user to convert ingredient measurements to metric · Measurement · Constructor(s) 5 The application shall allow the user to import pictures to recipes · Recipe
  • 21. · importPhoto() · Display · Display and format picture for browsing, viewing, editing recipes 6 The application shall allow the user to export “printer friendly” recipes · FacebookIntegration · postRecipe(Recipe recipe) · Display · Display and Format recipe 7 The application shall allow the user to share printer friendly recipes to social media · FacebookIntegration · postRecipe(Recipe recipe) · facebookClient.publish() · Display · Displays confirmation 8 The application shall allow the user to create a shopping list from recipes · ShoppingList · List of recipe items · Display · Displays recipe items needed 9 The application shall allow the user to add or remove ingredients from their “pantry” · Pantry · addIngredient() · removeIngredient() · Display · Display Ingredients 10 The application shall take into account the “pantry” inventory
  • 22. when generating shopping lists from recipes · ShoppingList · Recipe chosen from list · Pantry · Ingredients available for recipe · Display · Display items needed 11 The application shall allow the user to filter recipes in the following manners: · By ingredient · By diet · By cuisine · By meal · RecipeBook · recipeMethod(searchType) · Display · Display search results project_additions/pseudo-code.docx a. Input Subsystem: (a subclass of the Display Class) Class Input{ Takes input from the display and then sorts; }//end class Input b. Recipe Subsystem: Class Recipe{ String name; ArrayList[Ingredient] ingredientList;
  • 23. ArrayList ingredientMeasurements Enum dietType Enum cuisineType Enum mealType ArrayList[String] instructions; //Recipe Photo Constructor(){ } UpdateShoppingList(){ //update the shopping list with ingredients from this recipe that aren’t in the pantry } ImportPhoto(String filepath){ //create photo object and associate it with this recipe } toString(){ //format recipe } addIngredient(Ingredient ingredient, Measurement measurement){ ingredientList.add(ingredient) ingredientMeasurements.add(measurement) } removeIngredient(int ingredientListIndex){ ingredientList.remove(ingredientListIndex) ingredientMeasurements.remove(ingredientListIndex) } setDietType(Enum type){ dietType = type
  • 24. } setCuisineType(Enum type){ cuisineType = type } setMealType(Enum type){ mealType = type } addInstruction(String instruction){ instructions.add(instruction); } }//end class Recipe c. Ingredient Subsystem: Class Ingredient{ String name; //Ingredient photo String description importPhoto(String filepath){ //create photo object and associate it with this ingredient } setDescription(String desc){ description = desc } }//end class Ingredient d. Display Subsystem:
  • 25. Class Display{ constructor(){ Create panels Create text boxes; } Tabs for recipe book, pantry, and shopping list Actionlisteners for search button Radio buttons, fields, etc. for filtering Menu buttons for adding recipe, ingredient }//end class Display e. Share to Social Media Subsystem: //restFB http://restfb.com/ Class FacebookIntegration{ FacebookClient facebookClient //object to access facebook data postRecipe(Recipe recipe){ facebookClient.publish(); //publish given recipe’s toString and photo } }//end class FacebookIntegration f. Shopping List Subsystem: Class ShoppingList{ ArrayList Ingredients; Constructor(){
  • 26. Initialize objects } addList(recipe){ Adds a recipe’s ingredients to the list, unless they are already in the pantry; } removeList(ingredient or index){ Removes an ingredient from the list; } toString(){ Returns a string version of the recipes ingredients; } }//end class ShoppingList g. Pantry Subsystem: Class Pantry{ ArrayList Ingredients Constructor(ingredient){ Initialize objects; }// end constructor addIngredient Method(ingredient){ If the ingredient is already in the list, then send popup saying that there is already and ingredient; Else add the ingredient to the pantry } removeIngredient Method(ingredient){ Iterate through Ingredients array list;
  • 27. Remove ingredient; Send confirmation dialogue to user; } toString(){ Returns the whole list of ingredients in string form; } }// end Pantry Class h. Recipe Book Subsystem: Class RecipeBook{ ArrayList Recipes; ArrayList SearchResults Constructor(){ Initialize object;s } Findrecipe method(searchtype){ If by name… then search by name; If by cusinetype… then by cusinetype; If by ingredients.. Then by ingredients; Adds to an arrayList of the search results And then returns the arraylist search results } addRecipe(){ Creates a recipe; Adds to recipe list; } removeRecipe(){
  • 28. Removes recipe from list; } } project_additions/Recipe.javaproject_additions/Recipe.javaimpo rt java.util.ArrayList; /** * Revisions * * | Revision # | Date | Description | Name | * +------------+-------+-----------------------+---------------+ * | 1 | 7/2 | First Draft | Chris | * +------------+-------+-----------------------+---------------+ * +------------+-------+-----------------------+---------------+ * | 2 | 7/9 | Added getters/setters | Josh | * +------------+-------+-----------------------+---------------+ * */ publicclassRecipe{ privateString recipeName; privateArrayList<MeasuredIngredient> ingredientList; privateArrayList<Ingredient> ingredients; privateDietType dietType; privateCuisineType cuisineType; privateMealType mealType; privateArrayList<String> instructions; publicRecipe(String name){ setRecipeName(name); ingredientList =newArrayList<>(); setDietType(DietType.NONE);
  • 29. setCuisineType(CuisineType.NONE); setMealType(MealType.NONE); instructions =newArrayList<>(); ingredients =newArrayList<>(); } publicRecipe(){ } publicvoid addIngredient(Ingredient ingredient,MeasuredIngredi ent measurement){ ingredients.add(ingredient); ingredientList.add(measurement); } publicvoid removeIngredient(int ingredientListIndex){ ingredientList.remove(ingredientListIndex); ingredientList.remove(ingredientListIndex); } publicvoid addInstruction(String instruction){ instructions.add(instruction); } publicString getRecipeName(){ return recipeName; } publicvoid setRecipeName(String recipeName){ this.recipeName = recipeName; } publicDietType getDietType(){ return dietType; }
  • 30. publicvoid setDietType(DietType dietType){ this.dietType = dietType; } publicCuisineType getCuisineType(){ return cuisineType; } publicvoid setCuisineType(CuisineType cuisineType){ this.cuisineType = cuisineType; } publicMealType getMealType(){ return mealType; } publicvoid setMealType(MealType mealType){ this.mealType = mealType; } } project_additions/RecipeBook.javaproject_additions/RecipeBoo k.java import java.util.ArrayList; /** * */ publicclassRecipeBook{ privateArrayList<String> recipes; privateArrayList<String> searchResults;
  • 31. publicRecipeBook(){ recipes =newArrayList<String>(); searchResults =newArrayList<String>(); } // private String findRecipe(String searchType) { // String result =""; // ArrayList<String> searchResults = new ArrayList<String>(); // ArrayList<String> recipes = new ArrayList<String>(); // if (searchType.equals("name")) { /// will be using comparator to sort by name, cuisine etc... // } // searchResults.add(new recipes()); //} publicvoid addRecipe(String name,String instruction,String ingr edients,String cusine){ //Adds to recipe list; ArrayList<String> recipes =newArrayList<String>(); //removals will be selected via GUI recipes.add(name); recipes.add(instruction); recipes.add(ingredients); recipes.add(cusine); } publicvoid removeRecipe(String name,String instruction,String ingredients,String cusine){ //Removes recipe from list; ArrayList<String> recipes =newArrayList<String>();
  • 32. //removals will be selected via GUI recipes.remove(name); recipes.remove(instruction); recipes.remove(ingredients); recipes.remove(cusine); } publicString[] getIngsInRecipe(String recipe){ // TODO Auto-generated method stub returnnull; } publicObject getInstr(String recipe){ // TODO Auto-generated method stub returnnull; } } /* This is the psuedo- code from the Design document for the RecipeBook Class ArrayList Recipes; ArrayList SearchResults Constructor(){ Initialize object;s } Findrecipe method(searchtype){ If by name… then search by name; If by cusinetype… then by cusinetype; If by ingredients.. Then by ingredients;
  • 33. Adds to an arrayList of the search results And then returns the arraylist search results } addRecipe(){ Creates a recipe; Adds to recipe list; } removeRecipe(){ Removes recipe from list; } } */ project_additions/requirements_Document.txt The focus is on requirement number 2, 3, and 11 project_additions/tasks.txt 1.) The application shall allow the user to browse recipes: RecipeBook -> list all Display class ->Browse RecipeBook and view Recipe ==== 2.) The application shall allow the user to edit recipes:
  • 34. RecipeBook class->removeRecipe() RecipeBook class-> addRecipe() ==== 3.) The application shall allow the user to filter recipes in the following manners: • By ingredient (enum FROM Ingredient class) • By diet (enum from DietType class)-(VEGETARIAN, VEGAN) • By cuisine (enum from CuisineType class) (ITALIAN, MEXICAN, THAI, AMERICAN, JAPANESE, CHINESE, FRENCH, VIETNAMESE, KOREAN) • By meal ((enum from MealType class)) (BREAKFAST, LUNCH, DINNER, SNACK, BRUNCH, DESSERT, NONE) RecipeBook class -> recipeMethod(searchType) Display class -> Display search results ==== the recipebook class should really be just adding to a list creating a recipe and adding to the list
  • 35. deleting a recipe from a list and using a search target to search a list using loops to just iterate through and find a recipe by a certain tag such as name project/CuisineType.javaproject/CuisineType.javapublic enum CuisineType{ ITALIAN, MEXICAN, THAI, AMERICAN, JAPANESE, CHI NESE, FRENCH, VIETNAMESE, KOREAN, NONE } project/Design_Doc.docx
  • 36. Display Class Display Constructor: Create panels Create textBoxes Actionlisteners for seach button Menu Button for adding recipe Input Class (sub-class of Display) Sorts Input from Display Class ShoppingList Class ArrayList: Recipes ShoppingList Constructor: Initialization of Objects addList(recipe) removeList(recipe) toString(): formatting
  • 37. Adds to recipe list Removes from List 1 Display Constructor: Create panels Create textBoxes Pantry Class Pantry Constructor: Initialization of Objects addIngredient Method(ingredient) removeIngredient Method(ingredient) toString(): formatting ArrayList: Ingredients IF: on the list Send notification prompt Else: not on the list Add to the List Remove from List Send notification prompt 1 Recipe Class String: Name
  • 38. ArrayList: ingredientList ArrayList: instructions Recipe Constructor: (name, Temperature, instructions) ArrayList: ingredientMeasurements Enum: dietType Enum: cuisineType Enum: mealType UpdateShoppingList() Items not in pantry ImportPhoto(String filepath) toString(): formatting addIngredient(Ingredie nt ingredient, int measurement) removeIngredient(int ingredientListIndex) setDietType(Enum type) setCuisineType(Enum type) addInstruction(String instruction) setMealType(Enum type) 1 RecipeBook Class
  • 39. RecipeBook Constructor: Initialization of Objects addRecipe() removeRecipe() ArrayList: Recipes ArrayList: SearchResults Recipe Creation Removes from List Adds to List Findrecipe method (searchtype) IF by name / cusineType / ingredients THEN by name / cusineType / ingredients 1 Ingredient Class String: Name String: Description importPhoto(String filepath) Create and associate photo with ingredient setDecription(String desc):
  • 40. Description = desc FacebookIntegration Object: FacebookClient facebookClient postRecipe(Recipe recipe) facebookClient.publish(); 1 project/DietType.javaproject/DietType.javapublic enum DietTy pe{ VEGETARIAN, VEGAN, NONE } project/Display.javaproject/Display.javaimport javax.swing.JFra me; import java.awt.CardLayout; import javax.swing.JPanel; import javax.swing.JButton; import java.awt.event.ActionListener; import java.util.ArrayList; import java.util.HashSet; import java.util.Set; import java.awt.event.ActionEvent; import javax.swing.JTextField; import javax.swing.JLabel; import java.awt.GridLayout; publicclassDisplay{ privateJFrame frame;
  • 41. privateJTextField txtIngredient; privateRecipe recipe =newRecipe(); privateRecipeBook book =newRecipeBook(); /** * Launch the application. test */ publicstaticvoid main(String[] args){ //TODO:Hardcoding ingredients, These will be replaced by the i nput from the screen Display display =newDisplay(); display.frame.setVisible(true); } /** * Create the application. */ publicDisplay(){ initialize(); } /** * Initialize the contents of the frame. */ privatevoid initialize(){ frame =newJFrame(); frame.setBounds(100,100,450,300); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOS E); frame.getContentPane().setLayout(newCardLayout(0,0)); frame.setTitle("Welcome to your pantry!"); finalJPanel panelInitialScreen =newJPanel();
  • 42. panelInitialScreen.setLayout(null); panelInitialScreen.setVisible(true); finalJPanel panelRecipeChoicesScreen =newJPanel(); panelRecipeChoicesScreen.setLayout(null); panelRecipeChoicesScreen.setVisible(false); finalJPanel panelRecipeInstructionsScreen =newJPanel(); frame.getContentPane().add(panelRecipeInstructionsScree n,"name_293133281550638"); panelRecipeInstructionsScree n.setLayout(null); panelRecipeInstructionsScreen.setVisible(false); finalJPanel panelGroceryListScreen =newJPanel(); panelGroceryListScreen.setLayout(null); JButton btnGetRecipes =newJButton("Get Recipes"); btnGetRecipes.addActionListener(newActionListener(){ publicvoid actionPerformed(ActionEvent e){ if(myPantry.getIngredients().isEmpty()){ }else{ panelRecipeChoicesScreen.setVisible(true); panelRecipeChoicesScreen.setLayout(newGridLay out(0,1)); //Get the recipes that contain myPantry's ingredients Set<String> recipsToDisplay=newHashSet<String>(); for(String ingredient:myPantry.getIngredients()){
  • 43. for(String recipe:myCookbook.getRecipsFromIng(ingredient)){ recipsToDisplay.add(recipe); } } //Add the buttons to display JButton[] buttons=newJButton[recipsToDisplay.size()]; int index=0; for(finalString recipe:recipsToDisplay){ //Make an array of buttons so you can add action listeners to eac h one to //display the recipe in the recipe screen JPanel, or the grocery li st if //the pantry is missing some ingredients buttons[index]=newJButton(recipe); buttons[index].addActionListener(newActionLi stener(){ publicvoid actionPerformed(ActionEvent e){ // check if you have everything the recipe asks for and show //the recipe if so, otherwise show the grocery list String[] ingsInRecipe=myCookbook.getIngsInRecipe(recipe); boolean gotAllIngs=true; ArrayList<String> groceryList=newArrayList<String>(); for(String ing:ingsInRecipe){ if(!myPantry.getIngredients().contains(ing)){ gotAllIngs=false; groceryList.add(ing); } } for(String instruction:myCookbook.getInstr(recipe)){ panelRecipeInstructionsScreen.add(new JLabel(instruction)); } panelRecipeInstructionsScreen.setLayout( newGridLayout(0,1)); JButton doneCookingButton=newJButton("Done Cooking");
  • 44. panelRecipeInstructionsScreen.add(doneC ookingButton); doneCookingButton.addActionListener(ne wActionListener(){ @Override publicvoid actionPerformed(ActionEvent e){ frame.dispose(); } }); if(gotAllIngs){ //Display recipe panelRecipeInstructionsScreen.setVisib le(true); frame.setTitle("Cook Away!"); panelRecipeChoicesScreen.setVisible(f alse); } else{ //Display grocery list panelGroceryListScreen.setLayout(new GridLayout(0,1)); JLabel lblWeDisplayThe =newJLabel("You're missing these ing redients!"); panelGroceryListScreen.add(lblWeDisp layThe); for(String ing:groceryList){ javax.swing.JCheckBox box=new jav ax.swing.JCheckBox(); box.setText(ing); panelGroceryListScreen.add(box); } JButton nextButton=newJButton("next"); panelGroceryListScreen.add(nextButton ); nextButton.addActionListener(newActi
  • 45. onListener(){ @Override publicvoid actionPerformed(ActionEvent e){ //Display the recipe! //Add the right recipe to the screen first panelRecipeInstructionsScreen.set Visible(true); panelGroceryListScreen.setVisibl e(false); frame.setTitle("Cook Away!"); } }); panelGroceryListScreen.setVisible(true ); panelRecipeChoicesScreen.setVisible(f alse); frame.setTitle("Grocery List"); } } }); panelRecipeChoicesScreen.add(buttons[index]); index++; } panelInitialScreen.setVisible(false); frame.setTitle("Recipe Suggestions"); } } }); btnGetRecipes.setBounds(138,182,117,29); panelInitialScreen.add(btnGetRecipes); txtIngredient =newJTextField();
  • 46. txtIngredient.setBounds(112,4,130,28); txtIngredient.setText("Ingredient"); panelInitialScreen.add(txtIngredient); txtIngredient.setColumns(10); JButton btnAddIngButton =newJButton("Enter"); btnAddIngButton.addActionListener(newActionListener(){ publicvoid actionPerformed(ActionEvent e){ //TODO System.out.println(txtIngredient.getText()); myPantry.addIngredient(txtIngredient.getText()); } }); btnAddIngButton.setBounds(254,5,76,29); panelInitialScreen.add(btnAddIngButton); } } project/Ingredient.javaproject/Ingredient.javaimport java.awt.im age.BufferedImage; publicclassIngredient{ publicString ingredientName; publicBufferedImage photo; publicString description; publicIngredient(String name,String desc){ ingredientName = name; photo =null;
  • 47. description = desc; } } project/MealType.javaproject/MealType.javapublic enum MealT ype{ BREAKFAST, LUNCH, DINNER, SNACK, BRUNCH, DESS ERT, NONE } project/MeasuredIngredient.javaproject/MeasuredIngredient.jav apublicclassMeasuredIngredientextendsIngredient{ publicMeasurementType measurementType; publicfloat measurementAmount; publicString specialInstructions; publicMeasuredIngredient(Ingredient ingredient,MeasurementT ype type, float amount,String instructions){ super(ingredient.ingredientName, ingredient.description); measurementType = type; measurementAmount = amount; specialInstructions = instructions; } } project/MeasurementType.javaproject/MeasurementType.javaim port java.util.EnumSet; public enum MeasurementType{ CUP, TEASPOON, TABLESPOON, FLUID_OUNCE, MILLI
  • 48. LITER, LITER, DECILITER, POUND, OUNCE, MILIGRAM, GRAM, KILOGRAM; publicstaticEnumSet<MeasurementType> volume =EnumSet.of( CUP, TEASPOON, TABLESPOON, FLUID_OUNCE, MILLILITER, LITER , DECILITER); publicstaticEnumSet<MeasurementType> mass =EnumSet.of(PO UND, OUNCE, MILIGRAM, GRAM, KILOGRAM); } project/project_requirements.docx Requirement # Description Task 1 The application shall allow the user to manually input recipes · Ingredient · Fields · constructor(s) · MeasuredIngredient · Subclass of Ingredient that represents a measured quantity of a unique ingredient in the pantry · Extra fields for amount, measurementType, and specialInstructions · constructor(s) · Recipe · Fields · Constructor(s) · Display · Prompt user for new recipe fields, new ingredient fields, save recipe and prompt for a new recipe · Input
  • 49. 2 The application shall allow the user to browse recipes · RecipeBook · Display · Browse RecipeBook and view Recipe 3 The application shall allow the user to edit recipes · RecipeBook · removeRecipe() · addRecipe() 4 The application shall allow the user to convert ingredient measurements to metric · Measurement · Constructor(s) 5 The application shall allow the user to import pictures to recipes · Recipe · importPhoto() · Display · Display and format picture for browsing, viewing, editing recipes 6 The application shall allow the user to export “printer friendly” recipes · FacebookIntegration · postRecipe(Recipe recipe) · Display · Display and Format recipe 7 The application shall allow the user to share printer friendly recipes to social media · FacebookIntegration · postRecipe(Recipe recipe)
  • 50. · facebookClient.publish() · Display · Displays confirmation 8 The application shall allow the user to create a shopping list from recipes · ShoppingList · List of recipe items · Display · Displays recipe items needed 9 The application shall allow the user to add or remove ingredients from their “pantry” · Pantry · addIngredient() · removeIngredient() · Display · Display Ingredients 10 The application shall take into account the “pantry” inventory when generating shopping lists from recipes · ShoppingList · Recipe chosen from list · Pantry · Ingredients available for recipe · Display · Display items needed 11 The application shall allow the user to filter recipes in the following manners: · By ingredient · By diet · By cuisine · By meal · RecipeBook · recipeMethod(searchType)
  • 51. · Display · Display search results project/pseudo-code.docx a. Input Subsystem: (a subclass of the Display Class) Class Input{ Takes input from the display and then sorts; }//end class Input b. Recipe Subsystem: Class Recipe{ String name; ArrayList[Ingredient] ingredientList; ArrayList ingredientMeasurements Enum dietType Enum cuisineType Enum mealType ArrayList[String] instructions; //Recipe Photo Constructor(){ } UpdateShoppingList(){ //update the shopping list with ingredients from this recipe that aren’t in the pantry } ImportPhoto(String filepath){
  • 52. //create photo object and associate it with this recipe } toString(){ //format recipe } addIngredient(Ingredient ingredient, Measurement measurement){ ingredientList.add(ingredient) ingredientMeasurements.add(measurement) } removeIngredient(int ingredientListIndex){ ingredientList.remove(ingredientListIndex) ingredientMeasurements.remove(ingredientListIndex) } setDietType(Enum type){ dietType = type } setCuisineType(Enum type){ cuisineType = type } setMealType(Enum type){ mealType = type } addInstruction(String instruction){ instructions.add(instruction); } }//end class Recipe
  • 53. c. Ingredient Subsystem: Class Ingredient{ String name; //Ingredient photo String description importPhoto(String filepath){ //create photo object and associate it with this ingredient } setDescription(String desc){ description = desc } }//end class Ingredient d. Display Subsystem: Class Display{ constructor(){ Create panels Create text boxes; } Tabs for recipe book, pantry, and shopping list Actionlisteners for search button Radio buttons, fields, etc. for filtering Menu buttons for adding recipe, ingredient }//end class Display e. Share to Social Media Subsystem:
  • 54. //restFB http://restfb.com/ Class FacebookIntegration{ FacebookClient facebookClient //object to access facebook data postRecipe(Recipe recipe){ facebookClient.publish(); //publish given recipe’s toString and photo } }//end class FacebookIntegration f. Shopping List Subsystem: Class ShoppingList{ ArrayList Ingredients; Constructor(){ Initialize objects } addList(recipe){ Adds a recipe’s ingredients to the list, unless they are already in the pantry; } removeList(ingredient or index){ Removes an ingredient from the list; } toString(){ Returns a string version of the recipes ingredients; }
  • 55. }//end class ShoppingList g. Pantry Subsystem: Class Pantry{ ArrayList Ingredients Constructor(ingredient){ Initialize objects; }// end constructor addIngredient Method(ingredient){ If the ingredient is already in the list, then send popup saying that there is already and ingredient; Else add the ingredient to the pantry } removeIngredient Method(ingredient){ Iterate through Ingredients array list; Remove ingredient; Send confirmation dialogue to user; } toString(){ Returns the whole list of ingredients in string form; } }// end Pantry Class h. Recipe Book Subsystem: Class RecipeBook{ ArrayList Recipes; ArrayList SearchResults
  • 56. Constructor(){ Initialize object;s } Findrecipe method(searchtype){ If by name… then search by name; If by cusinetype… then by cusinetype; If by ingredients.. Then by ingredients; Adds to an arrayList of the search results And then returns the arraylist search results } addRecipe(){ Creates a recipe; Adds to recipe list; } removeRecipe(){ Removes recipe from list; } } project/Recipe.javaproject/Recipe.javaimport java.util.ArrayList ; publicclassRecipe{ privateString recipeName; privateArrayList<MeasuredIngredient> ingredientList; privateDietType dietType; privateCuisineType cuisineType; privateMealType mealType;
  • 57. privateArrayList<String> instructions; publicRecipe(String name){ recipeName = name; ingredientList =newArrayList<>(); dietType =DietType.NONE; cuisineType =CuisineType.NONE; mealType =MealType.NONE; instructions =newArrayList<>(); } } project/RecipeBook.javaproject/RecipeBook.java/* * To change this license header, choose License Headers in Pro ject Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package recipebook; import java.util.ArrayList; import java.util.Scanner; /** * Revisions * * | Revision # | Date | Description | Name | * +------------+-------+-----------------------+---------------+ * | 1 | 7/2 | First Draft | Joshua | * +------------+-------+-----------------------+---------------+ * */ publicclassRecipeBook{
  • 58. privateScanner sc =newScanner(System.in);//for testing publicRecipeBook(){ ArrayList<String> recipes =newArrayList<String>(); ArrayList<String> searchResults =newArrayList<String>(); Scanner sc =newScanner(System.in);//for testing } // private String findRecipe(String searchType) { // String result =""; // ArrayList<String> searchResults = new ArrayList<String>(); // ArrayList<String> recipes = new ArrayList<String>(); // if (searchType.equals("name")) { /// will be using comparator to sort by name, cuisine etc... // } // searchResults.add(new recipes()); //} publicvoid addRecipe(String name,String instruction,String ingr edients,String cusine){ //Adds to recipe list; ArrayList<String> recipes =newArrayList<String>(); //removals will be selected via GUI recipes.add(name); recipes.add(instruction); recipes.add(ingredients); recipes.add(cusine); } publicvoid removeRecipe(String name,String instruction,String ingredients,String cusine){
  • 59. //Removes recipe from list; ArrayList<String> recipes =newArrayList<String>(); //removals will be selected via GUI recipes.remove(name); recipes.remove(instruction); recipes.remove(ingredients); recipes.remove(cusine); } publicstaticvoid main(String[] args){ // TODO code application logic here } } /* This is the psuedo- code from the Design document for the RecipeBook Class ArrayList Recipes; ArrayList SearchResults Constructor(){ Initialize object;s } Findrecipe method(searchtype){ If by name… then search by name; If by cusinetype… then by cusinetype; If by ingredients.. Then by ingredients; Adds to an arrayList of the search results And then returns the arraylist search results }
  • 60. addRecipe(){ Creates a recipe; Adds to recipe list; } removeRecipe(){ Removes recipe from list; } } */ project/requirements_Document.txt The focus is on requirement number 2, 3, and 11 project/tasks.txt 1.) The application shall allow the user to browse recipes: RecipeBook -> list all Display class ->Browse RecipeBook and view Recipe ==== 2.) The application shall allow the user to edit recipes: RecipeBook class->removeRecipe() RecipeBook class-> addRecipe()
  • 61. ==== 3.) The application shall allow the user to filter recipes in the following manners: • By ingredient (enum FROM Ingredient class) • By diet (enum from DietType class)-(VEGETARIAN, VEGAN) • By cuisine (enum from CuisineType class) (ITALIAN, MEXICAN, THAI, AMERICAN, JAPANESE, CHINESE, FRENCH, VIETNAMESE, KOREAN) • By meal ((enum from MealType class)) (BREAKFAST, LUNCH, DINNER, SNACK, BRUNCH, DESSERT, NONE) RecipeBook class -> recipeMethod(searchType) Display class -> Display search results