0% found this document useful (0 votes)
13 views

Java project

Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

Java project

Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

Group Members

1. Tanatswa Olsen Mazambani T234821G


2. Fadzai Freteur Tembedza T20328470L
3. Payton Chirova T238017T
4. Gareth Chitate T2324004W
5. Mc Clifford Chikwaka T2336691E
6. Phillmon Kanjanda T239897
7. Tashinga Mubaiwa T231446B
8. Samuel Bomani T2328383E
Recipe Book Project Documentation
Project Title

Recipe Book : Flavors of France

Project Background
The Recipe Book project is designed to provide a user-friendly application for managing a collection of
recipes. In today's fast-paced environment, many individuals seek efficient ways to organize their culinary
creations, whether for personal use, sharing with friends, or managing dietary needs. This project aims to
fulfill that need by allowing users to add, view, and manage recipes in a structured manner.

Why Choose a Recipe Book?


When considering various project options such as a quiz application, library system, expense tracker, or
student record management, the Recipe Book project stands out for several reasons:

1. Universal Appeal: Cooking is a common interest that transcends age and background. A recipe book
can engage a wider audience compared to niche applications.

2. Rich Data Management: Recipes can include various data types (text, lists, images, etc.), making the
project an excellent exercise in data handling and management.

3. User Interaction: Unlike a static quiz or library system, a recipe book allows for dynamic user
interaction, providing a more engaging experience.

4. Creative Expression: Cooking is an art, and a recipe book allows users to express their creativity. This
aspect encourages users to contribute personal recipes, making the application more personalized.

5. Educational Component: Users can learn about different cuisines, ingredient substitutions, and cooking
techniques, adding an educational layer to the application.

Project Recipes

Recipe Format
Each recipe in the application will consist of:
- Name: The title of the recipe.
- Ingredients: A list of ingredients required for the recipe.
- Instructions: Step-by-step instructions for preparing the dish.
- Cooking Time: Estimated time to prepare and cook the dish.
Sample Recipes
1. Spaghetti Carbonara
- Ingredients: Spaghetti, eggs, pancetta, Parmesan cheese, black pepper.
- Instructions: Boil spaghetti. Cook pancetta. Mix eggs and cheese. Combine all and serve.
- Cooking Time: 20 minutes.

2. Chicken Curry
- Ingredients: Chicken, curry powder, coconut milk, onions, garlic, ginger.
- Instructions: Sauté onions, garlic, and ginger. Add chicken and curry powder. Stir in coconut milk and
simmer.
- Cooking Time: 40 minutes.

3. Vegetable Stir-fry
- Ingredients: Mixed vegetables, soy sauce, garlic, ginger, sesame oil.
- Instructions: Heat oil, sauté garlic and ginger, add vegetables, and stir-fry until tender. Add soy sauce.
- Cooking Time: 15 minutes.

Interface
The user interface will be designed using Java Swing, providing a graphical interface with the following
components:
- Main Window: Displays the title and menu options.
- Recipe Entry Form: Allows users to input new recipes.
- Recipe List Area: Displays the list of recipes and details for selected recipes.
- Buttons: For adding, viewing, and deleting recipes.
- A header displaying the application title.
- A text area for displaying recipes.
- Buttons for adding, removing, searching, importing, exporting, and updating recipes.
- Dialog boxes for user input, ensuring a seamless interaction.

Interface Design
- Text Fields: For entering recipe details.
- Text Area: For displaying recipe information.
- Buttons: For actions like "Add Recipe", "View Recipe", and "Delete Recipe".
Uses of the System
- Recipe Management: Users can add, view, and delete recipes.
- Search Functionality: Users can search for recipes by name or ingredient.
- Personalization: Users can save their favorite recipes for quick access.
- Educational Resource: Users can learn cooking techniques through the provided instructions.
- Home Cooking: Users can manage personal recipes effectively.
- Recipe Sharing: Import/export functionality facilitates sharing recipes with friends and family.
- Learning Tool: Users can discover new recipes and cooking techniques, enhancing their culinary skills.

Methods Used
Core Classes and Methods
- addRecipe(): Prompts the user for recipe details and adds a new recipe to the list.
- removeRecipe(): Allows users to remove a recipe by title.
- searchRecipe(): Searches for a recipe by title and displays its details.
- importRecipes(): Reads recipes from a text file and adds them to the list.
- exportRecipes(): Writes the current recipes to a text file in a specified format.
- updateRecipe(): Allows users to update existing recipes based on the title.
- updateDisplay(): Refreshes the text area to show the current list of recipes.

1. Recipe Class
- Attributes: Name, ingredients, instructions, and cooking time.
- Methods:
- `getName()`: Returns the name of the recipe.
- `getIngredients()`: Returns the list of ingredients.
- `getInstructions()`: Returns the cooking instructions.
- `toString()`: Returns a formatted string representation of the recipe.

2. RecipeBook Class
- Attributes: List of Recipe objects.
- Methods:
- `addRecipe(Recipe recipe)`: Adds a new recipe to the collection.
- `getRecipes()`: Returns the list of recipes.
- `findRecipe(String name)`: Searches for a recipe by name.

3. RecipeBookApp Class
- Methods:
- `createAndShowGUI()`: Sets up the user interface.
- `main(String[] args)`: Entry point of the application.

Tools Used
1. Java Development Kit (JDK): For developing the application.
2. Intellij Community Edition: The integrated development environment (IDE) used for coding,
write, compile, and run the application.
3. Java Swing: For creating the graphical user interface. A part of Java Foundation Classes (JFC)
used for building the graphical user interface.
4. Java: The programming language used for development.

Description of Code
The code for the Recipe Book application consists of three main classes:

1. Recipe Class:
- Manages individual recipe data. It encapsulates the recipe's name, ingredients, and instructions,
providing methods to retrieve this data.

2. RecipeBook Class:
- Manages a collection of Recipe objects. It allows adding new recipes and retrieving the list of existing
recipes.

3. RecipeBookApp Class:
- Contains the main method and initializes the application. It sets up the GUI, including input fields and
buttons. The `ActionListener` for buttons handles user interactions, such as adding a new recipe and
displaying it.

Example Code Snippet (Recipe Class)


java
public class Recipe {
private String name;
private String ingredients;
private String instructions;

public Recipe(String name, String ingredients, String instructions) {


this.name = name;
this.ingredients = ingredients;
this.instructions = instructions;
}

@Override
public String toString() {
return "Recipe: " + name + "\nIngredients: " + ingredients + "\nInstructions: " + instructions;
}
}

Example Code Snippet (RecipeBook Class)


java
public class RecipeBook {
private List<Recipe> recipes;

public RecipeBook() {
recipes = new ArrayList<>();
}

public void addRecipe(Recipe recipe) {


recipes.add(recipe);
}

public List<Recipe> getRecipes() {


return recipes;
}
}
4. Recipe Class: Represents a recipe with attributes for title, ingredients, instructions, and cooking time. It
includes constructors, getters, setters, and a `toString()` method for displaying recipe details.

java
public class Recipe {
// Fields
private String title;
private String ingredients;
private String instructions;
private String cookingTime;

// Constructor and methods...


}

5. RecipeBookApp Class: This is the main class that implements the user interface and contains the
application logic. It initializes the GUI components, sets up the event listeners for the buttons,
and manages the list of recipes.

java
public class RecipeBookApp {
private ArrayList<Recipe> recipes = new ArrayList<>();
private JFrame frame;
private JTextArea recipeDisplayArea;

// UI setup and event handling methods...


}

6. Main Method: The entry point of the application that creates an instance of the `RecipeBookApp`
class, launching the application.

java
public static void main(String[] args) {
new RecipeBookApp();
}

Example Code Snippet (RecipeBookApp Class)


java
public class RecipeBookApp {
public static void main(String[] args) {
SwingUtilities.invokeLater(() -> new RecipeBookApp().createAndShowGUI());
}

private void createAndShowGUI() {


// GUI setup code here
}
}
Code Structure
- Imports: Necessary libraries for GUI components and file handling are imported at the beginning of the
code.
- Main UI Components: The main frame, header, text area for displaying recipes, and button panel are
created and added to the frame.
- Action Listeners: Each button is associated with an action listener that defines what happens when the
button is clicked (e.g., adding a recipe or importing recipes).
Conclusion
The Recipe Book project serves as a comprehensive solution for managing recipes, combining user
interaction, data management, and educational value. It is an ideal project for demonstrating Java skills
while also being practical and engaging. This documentation provides a thorough overview of the
project's objectives, design, and implementation details, offering a solid foundation for further
development and enhancement.

You might also like