Skip to content

Practical work repository for the Programming Paradigms course at the National University of La Matanza (@unlam).

License

Notifications You must be signed in to change notification settings

hozlucas28/Java-Practical-Work-2025

Repository files navigation

Java Practical Work [2025] [WIP]

Repository for the practical work of the Programming Paradigms course
- UNLaM (National University of La Matanza) -

Summary • Features • Installation • Diagrams • Team workflow • Development team
Additional materialLicense • Acknowledgments

[ Spanish version ]

Preview

(demonstration video)

Summary

This repository contains the practical work for the Programming Paradigms course at the National University of La Matanza (UNLaM). The practical work consists of doing a crafting system in Java and testing it with JUnit 5.

Features

  • Architecture planning
  • Code conventions and standards
  • Code documentation
  • Collections
  • Commits following the Conventional Commits
  • Deployment of releases
  • E2E testing with JUnit 5
  • File reading and interpretation
  • Input control using validations
  • Local storage of records
  • Team Workflow planning (branches, tags, and releases)
  • Unit testing with JUnit 5

Installation

  1. Clone the repository to your device.
  2. Install Java and Prolog (check Add swipl to the system PATH option during the installation).
  3. Install Eclipse IDE for Java developers.
  4. Open the cloned repository with Eclipse IDE.
  5. Then, press right click on Main.java file and select Run As -> Java Application.
  6. That's all, enjoy the crafting system through the interaction with the console.
How can I run all JUnit tests?

If you want to run all JUnit tests, you have to press Right click on the project within Package explorer of Eclipse IDE, and select Run as -> JUnit Test. That's all, Eclipse IDE will start running all the tests.

How can I change the inventory?

To change the items in the inventory, you have to update the inventory.json file with the desired ones.

It's important to follow the same structure as the original ones, and these must be defined inside the recipes.json file.

How can I change the list of available items to craft?

To change the list of available items to craft, you must update the recipes.json file with the new craftable items.

It's important to follow the same structure as the original ones.

Known issues

Issue Solution
Prolog could not find system resources In Eclipse IDE, go to File tab and select Import option. Then, you have to search for Launch configurations, select it and press Next. After that, browse the project directory, select Java-Practical-Work-2025, Main, and PrologServiceTests files and check Overwrite existing launch configurations without warning. option. Finally, press Finish to load your local Prolog instance. If this didn't work, check out the value of each environment variable inside Environment tab in each run configurations of Java-Practical-Work-2025, Main, and PrologServiceTests, as they must aim to your local Prolog directory.

Diagrams

Class diagram
---
config:
  class:
    hideEmptyMembersBox: true

  theme: redux
  look: neo
  layout: elk
---
classDiagram
direction TB

    class ItemsRepository {
	    -HashMap~String, Item~ items

	    +HashMap~String, Item~ getItems()
	    +Item getItem(String name)
        +static ItemsRepository loadFromJSON(String path)
    }

    class PrologService {
	    -String baseItemFactName
	    -String ingredientFactName
	    -String itemInInventoryFactName
	    -ItemsRepository itemsRepository
	    -Inventory inventory

        +HashMap~Item, Integer~ craftableItems()
        -void toFile(FileWriter fWriter)
        -String toProlog(ItemsRepository itemsRepository)
        -String toProlog(Inventory inventory)
        -String utilityRules()
    }

    class PrologServiceBuilder {
	    #String baseItemFactName
	    #String ingredientFactName
	    #String itemInInventoryFactName
	    #ItemsRepository itemsRepository
	    #Inventory inventory

        +PrologServiceBuilder setBaseItemFactName(String baseItemFactName)
        +PrologServiceBuilder setIngredientFactName(String ingredientFactName)
        +PrologServiceBuilder setItemInInventoryFactName(String itemInInventoryFactName)
        +PrologServiceBuilder setItemsRepository(ItemsRepository itemsRepository)
        +PrologServiceBuilder setInventory(Inventory inventory)
        +PrologService build()
    }

    class Item {
	    -String name
	    -List~Recipe~ recipes

	    +String getName()
	    +List~Recipe~ getRecipes()
	    +bool isBase()
    }

    class Recipe {
	    -List~Ingredient~ ingredients
	    -int timeToCraftInMilliseconds
	    -int itemsToCraft
	    -Optional~Item~ craftingTable

	    +List~Item~ getIngredients()
	    +int getTimeToCraftInMilliseconds()
	    +int getItemsToCraft()
	    +List~Item~ getBaseIngredients()
	    +Optional~Item~ getCraftingTable()
    }

    class JSONRecipe {
        << Adapter >>

	    -HashMap~String, Integer~ ingredients
	    -int timeToCraftInMilliseconds
	    -int itemsToCraft
	    -Optional~Item~ craftingTable

	    +static void linkItemsWithRecipes(HashMap~String, Item~ items, HashMap~String, List~JSONRecipe~~ recipesPerItem)
    }

    class CraftedItem {
	    -ZonedDateTime date
	    -Recipe usedRecipe
	    -int craftedItems

	    +ZonedDateTime getDate()
	    +Recipe getUsedRecipe()
	    +int getCraftedItems()
    }

    class Inventory {
        -HashMap~Item, Integer~ items

	    +HashMap~Item, Integer~ getItems()
	    +Item getItemQuantity(Item item)
	    +void addItem(Item item, int quantity)
	    +void removeItem(Item item, int quantity)
        +void storeOnJSON(String path)
        +static Inventory loadFromJSON(String path)
    }

    class Ingredient {
	    -Item item
	    -int quantity

	    +Item getItem()
	    +int getQuantity()
    }

    class CraftingSystem {
	    -Inventory inventory
	    -HashMap~Item, Integer~ itemsToCraft
	    -CraftingHistory history
        +List~CraftedItem~ getCraftedItems()
	    +int getCraftableUnits()
        +HashMap~Item, HashMap~Recipe, List~Ingredient~~~ getMissingIngredients()
        +HashMap~Item, HashMap~Recipe, List~Ingredient~~~ getMissingBaseIngredients()
        -HashMap~~Item, HashMap~Recipe, List~Ingredient~~~ getMissingIngredients()
	    +HashMap~Item, HashMap~Recipe, List~Ingredient~~~ getRequiredIngredients()
        +HashMap~Item, HashMap~Recipe, List<Ingredient~~~ getRequiredBaseIngredients()
        -List~Ingredient~ getBaseIngredientsRecursive(Recipe recipe, int totalToCraft)
	    +bool canCraft()
	    +CraftingSystem setItemsToCraft(HashMap~Item, Integer~ items)
	    +void craftItems()
	    +bool undoLastCraft()
    }

    class CraftingHistory {
	    -List~CraftedItem~ items

        +List~CraftedItem~ getItems()
        +CraftedItem getLastItem()
	    +void addItem(Item item, Recipe usedRecipe)
	    +CraftedItem removeLastItem()
    }

    ItemsRepository "1" --o "0...*" Item : Has
    ItemsRepository "1" --* "1...*" JSONRecipe : Instance and uses the static method

    PrologService "1" --o "1" Inventory : Has a reference to
    PrologService "1" --o "1" ItemsRepository : Has a reference to
    PrologService "1" --* "1" PrologServiceBuilder : Build by

    Item "1" --o "0...*" Recipe : Has

    Recipe "1" --o "1...*" Ingredient : Has
    Recipe "1" --o "0...1" Item : Has a reference to

    JSONRecipe "1" --o "0...1" Item : Has

    CraftedItem --|>  Item : Inherits from

    Inventory "1" --o "0...*" Item : Has references to

    CraftingSystem "1*" --o "0..." Item : Has references to
    CraftingSystem "1" --o "1" Inventory : Has a reference to
    CraftingSystem "1" --* "1" CraftingHistory : Has

    CraftingHistory "1" --o "0...*" CraftedItem : Has
Loading

Note

The diagrams were developed from scratch as part of the preliminary project reports.

Team workflow

---
config:
  logLevel: debug
  theme: base
  gitGraph:
    showBranches: true
    showCommitLabel: true
    mainBranchName: Master
    parallelCommits: true
---
gitGraph:
        commit
        commit tag: "v0.0.1"
        branch "Aguilera Emanuel"
        commit
        commit
        checkout Master
        branch "De Marco Juan"
        commit
        commit
        checkout Master
        branch "Hoz Lucas"
        commit
        commit
        checkout Master
        branch "Rueda Olarte Joel"
        commit
        commit
        checkout Master
        branch "Maudet Alejandro"
        commit
        commit
        checkout Master
        branch "Monges Omar"
        commit
        commit
        checkout Master
        merge "De Marco Juan"
        merge "Aguilera Emanuel"
        merge "Rueda Olarte Joel"
        merge "Maudet Alejandro"
        merge "Hoz Lucas"
        merge "Monges Omar" tag: "v1.0.0"
Loading

Tags

  • vMAJOR.MINOR.PATCH: This tag indicates a release of the practical work following Semantic Versioning, and will only be present in the Master branch commits.

Branches

  • Master: Branch containing the development versions of the practical work, where team members will introduce new changes (commits).

Important

Stable versions are only available as releases.

Note

The other branches are fictional and represent individual contributions from each member to the Master branch.

Development team

Additional material

License

This repository is under the MIT License. For more information about what is permitted with the contents of this repository, visit choosealicense.com.

Acknowledgments

We would like to thank the teachers from the UNLaM Programming Paradigms course for their support and guidance.

About

Practical work repository for the Programming Paradigms course at the National University of La Matanza (@unlam).

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Contributors 2

  •  
  •  

Languages