{"id":22352797,"url":"https://github.com/alinpahontu2912/energy-system","last_synced_at":"2026-07-02T17:32:32.607Z","repository":{"id":207572107,"uuid":"327306493","full_name":"alinpahontu2912/Energy-System","owner":"alinpahontu2912","description":"2-part project for OOP course","archived":false,"fork":false,"pushed_at":"2021-01-21T14:31:43.000Z","size":23,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-23T13:51:28.778Z","etag":null,"topics":["design-patterns","oop"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alinpahontu2912.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2021-01-06T12:35:05.000Z","updated_at":"2021-07-28T19:43:22.000Z","dependencies_parsed_at":"2023-11-16T14:45:29.311Z","dependency_job_id":null,"html_url":"https://github.com/alinpahontu2912/Energy-System","commit_stats":null,"previous_names":["alinpahontu2912/energy-system"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/alinpahontu2912/Energy-System","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alinpahontu2912%2FEnergy-System","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alinpahontu2912%2FEnergy-System/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alinpahontu2912%2FEnergy-System/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alinpahontu2912%2FEnergy-System/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alinpahontu2912","download_url":"https://codeload.github.com/alinpahontu2912/Energy-System/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alinpahontu2912%2FEnergy-System/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35056882,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-02T02:00:06.368Z","response_time":173,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["design-patterns","oop"],"created_at":"2024-12-04T12:27:12.341Z","updated_at":"2026-07-02T17:32:32.590Z","avatar_url":"https://github.com/alinpahontu2912.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Energy-System - 2-part project for OOP course\n\n## Packages:\n\n### entities:\n\n- contains Producer, Consumer, Distributor and abstract class Entity, \nwhich has the common fields of both consumers and distributors \n(id, budget, isBankrupt)\n- both Consumer and Distributor classes extend Entity\n- the package contains a singleton entities factory that creates\nconsumers or distributors\n- Consumer implements Comparable interface, to allow for easy sorting\nafter specified criteria(first after remaining contract months, and then by id)\n- Distributor implements Observer interface, to receive updates concerning\nthe need to change its producers \n- Producer extends Observable and notifies its Distributors every time\na change in production prices happen (this is done using the warnDistributors\nmethod)\n- Distributor has the following specific functions:\n    - profit () -\u003e used to calculate the wanted profit \n    - contractPrice() -\u003e used to compute the price of the contract\n    - monthlyExpenses() -\u003e calculates the expenses of the distributor\n- Distributors also have a list of their contract prices history for every\nmonth of the game simulation\n- Producers hold their monthly stats about distributors in a map\n\n### ioutils:\n\n- contains InputReader and Output classes\n- those classes contain specific methods for reading and writing data\nto files\n!Used the @supresswarnings(\"unchecked\") because the org.json.simple\nlibrary uses raw HashMap types!\n\n### utilities:\n\n- contains Constants class, which has strings to be used while reading \nand writing data to files\n- contains the Utilities class, a class whose methods are used to solve\nthe simulations\n- this class contains methods for:\n    - assigning each distributor producers\n    - calculating distributor contract prices\n    - checking if there are valid distributors\n    - finding the cheapest non-bankrupt distributor\n    - assign non-Bankrupt consumers with no contract to cheapest distributor\n    - counting the remaining contracts of the distributors\n    - paying the consumers (giving them their monthly income)\n    - making distributors pay their monthly expenses\n    - paying the distributors(consumers paying their contracts)\n    - removing bankrupt consumers from the distributor's list\n    - resetting the relations between distributors and producers\n    - creating the monthly distributor stats of a producer\n    - creating a list of distributor contract prices history\n    - finding a producer by its id\n\n### strategies:\n\n- contains the interface EnergyStrategy, which has a method for sorting\na list of producers\n- GreenStrategy class implements EnergyStrategy and sorts producers based on\nwhether they use renewable energy sources, then by price and then by quantity of\nenergy they can give\n- PriceStrategy class implements EnergyStrategy and sorts producers based on price\nand then by quantity of energy they can give \n- QuantityStrategy class implements EnergyStrategy and sorts producers based on \nquantity of energy they can give\n- If the type of energy and the price are equal, producers will be sorted by\ntheir id number\n\n### The Main class and the logic behind the entire program:\n\n- I read the initial data from the files, using my inputReader\n- If the number of the simulation is greater than 0, I update consumers, \ndistributors and producer data\n- I calculate the contract prices and choose the cheapest distributor \n- I assign consumers with no contract to the cheapest distributor and then reset\nthe number of consumers of every distributor\n- I pay my consumers, then they pay their distributors and then the distributors\npay their monthly expenses\n- I reset the relations between observers and observables (producer - distributor)\n- I assign distributors to their producers, if needed\n- I calculate the production cost again\n- Before a new round, I remove the Bankrupt consumers from the distributors' list:\n- I create a map that shows me all the producers' distributors in a specific month\n- I create a map that contains the contract prices of every distributor for every month\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falinpahontu2912%2Fenergy-system","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falinpahontu2912%2Fenergy-system","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falinpahontu2912%2Fenergy-system/lists"}