diff --git a/1ano/2semestre/c2/cadernos/Series-De-Potencias_Taylor.pdf b/1ano/2semestre/c2/cadernos/Caderno1-Series-De-Potencias_Taylor.pdf similarity index 100% rename from 1ano/2semestre/c2/cadernos/Series-De-Potencias_Taylor.pdf rename to 1ano/2semestre/c2/cadernos/Caderno1-Series-De-Potencias_Taylor.pdf diff --git a/1ano/2semestre/c2/cadernos/Series-De-Funcoes.pdf b/1ano/2semestre/c2/cadernos/Caderno2-Series-De-Funcoes.pdf similarity index 100% rename from 1ano/2semestre/c2/cadernos/Series-De-Funcoes.pdf rename to 1ano/2semestre/c2/cadernos/Caderno2-Series-De-Funcoes.pdf diff --git a/1ano/2semestre/c2/cadernos/Series-Fourier.pdf b/1ano/2semestre/c2/cadernos/Caderno3-Series-Fourier.pdf similarity index 100% rename from 1ano/2semestre/c2/cadernos/Series-Fourier.pdf rename to 1ano/2semestre/c2/cadernos/Caderno3-Series-Fourier.pdf diff --git a/1ano/2semestre/c2/fichas/f1_SP_FT_2223.pdf b/1ano/2semestre/c2/fichas/enunciados/f1_SP_FT_2223.pdf similarity index 93% rename from 1ano/2semestre/c2/fichas/f1_SP_FT_2223.pdf rename to 1ano/2semestre/c2/fichas/enunciados/f1_SP_FT_2223.pdf index f1afca7..b951863 100644 Binary files a/1ano/2semestre/c2/fichas/f1_SP_FT_2223.pdf and b/1ano/2semestre/c2/fichas/enunciados/f1_SP_FT_2223.pdf differ diff --git a/1ano/2semestre/c2/fichas/f2_SF_2223.pdf b/1ano/2semestre/c2/fichas/enunciados/f2_SF_2223.pdf similarity index 94% rename from 1ano/2semestre/c2/fichas/f2_SF_2223.pdf rename to 1ano/2semestre/c2/fichas/enunciados/f2_SF_2223.pdf index 4a0043a..b494ce8 100644 Binary files a/1ano/2semestre/c2/fichas/f2_SF_2223.pdf and b/1ano/2semestre/c2/fichas/enunciados/f2_SF_2223.pdf differ diff --git a/1ano/2semestre/c2/fichas/enunciados/f3_Extremos_2223.pdf b/1ano/2semestre/c2/fichas/enunciados/f3_Extremos_2223.pdf new file mode 100644 index 0000000..d500d6a Binary files /dev/null and b/1ano/2semestre/c2/fichas/enunciados/f3_Extremos_2223.pdf differ diff --git a/1ano/2semestre/c2/fichas/solucoes/f3_Extremos_2223_sol.pdf b/1ano/2semestre/c2/fichas/solucoes/f3_Extremos_2223_sol.pdf new file mode 100644 index 0000000..0e1a700 Binary files /dev/null and b/1ano/2semestre/c2/fichas/solucoes/f3_Extremos_2223_sol.pdf differ diff --git a/1ano/2semestre/c2/slides/slides_c2ag4_cap3_parte1_def.pdf b/1ano/2semestre/c2/slides/slides_c2ag4_cap3_parte1_def.pdf new file mode 100644 index 0000000..60f4f1e Binary files /dev/null and b/1ano/2semestre/c2/slides/slides_c2ag4_cap3_parte1_def.pdf differ diff --git a/1ano/2semestre/c2/slides/slides_c2ag4_cap3_parte2_def.pdf b/1ano/2semestre/c2/slides/slides_c2ag4_cap3_parte2_def.pdf new file mode 100644 index 0000000..691152a Binary files /dev/null and b/1ano/2semestre/c2/slides/slides_c2ag4_cap3_parte2_def.pdf differ diff --git a/1ano/2semestre/c2/testes/2020-2021/recurso_2021_moodle.pdf b/1ano/2semestre/c2/testes/2020-2021/recurso_2021_moodle.pdf new file mode 100644 index 0000000..de36ceb Binary files /dev/null and b/1ano/2semestre/c2/testes/2020-2021/recurso_2021_moodle.pdf differ diff --git a/1ano/2semestre/c2/testes/2020-2021/recurso_2021_resolvido.pdf b/1ano/2semestre/c2/testes/2020-2021/recurso_2021_resolvido.pdf new file mode 100644 index 0000000..696b0b3 Binary files /dev/null and b/1ano/2semestre/c2/testes/2020-2021/recurso_2021_resolvido.pdf differ diff --git a/1ano/2semestre/c2/testes/2020-2021/t1_2021_moodle.pdf b/1ano/2semestre/c2/testes/2020-2021/t1_2021_moodle.pdf new file mode 100644 index 0000000..359a6cb Binary files /dev/null and b/1ano/2semestre/c2/testes/2020-2021/t1_2021_moodle.pdf differ diff --git a/1ano/2semestre/c2/testes/2020-2021/t1_2021_resolvido_moodle.pdf b/1ano/2semestre/c2/testes/2020-2021/t1_2021_resolvido_moodle.pdf new file mode 100644 index 0000000..d70899e Binary files /dev/null and b/1ano/2semestre/c2/testes/2020-2021/t1_2021_resolvido_moodle.pdf differ diff --git a/1ano/2semestre/c2/testes/2020-2021/t2_2021.pdf b/1ano/2semestre/c2/testes/2020-2021/t2_2021.pdf new file mode 100644 index 0000000..052b619 Binary files /dev/null and b/1ano/2semestre/c2/testes/2020-2021/t2_2021.pdf differ diff --git a/1ano/2semestre/c2/testes/2020-2021/t2_2021_resolvido.pdf b/1ano/2semestre/c2/testes/2020-2021/t2_2021_resolvido.pdf new file mode 100644 index 0000000..ac81e92 Binary files /dev/null and b/1ano/2semestre/c2/testes/2020-2021/t2_2021_resolvido.pdf differ diff --git a/1ano/2semestre/c2/testes/2021-2022/moodle_exfinal_2122.pdf b/1ano/2semestre/c2/testes/2021-2022/moodle_exfinal_2122.pdf new file mode 100644 index 0000000..64acad5 Binary files /dev/null and b/1ano/2semestre/c2/testes/2021-2022/moodle_exfinal_2122.pdf differ diff --git a/1ano/2semestre/c2/testes/2021-2022/moodle_exre_2122.pdf b/1ano/2semestre/c2/testes/2021-2022/moodle_exre_2122.pdf new file mode 100644 index 0000000..e57b78a Binary files /dev/null and b/1ano/2semestre/c2/testes/2021-2022/moodle_exre_2122.pdf differ diff --git a/1ano/2semestre/c2/testes/2021-2022/moodle_t1_2122.pdf b/1ano/2semestre/c2/testes/2021-2022/moodle_t1_2122.pdf new file mode 100644 index 0000000..7061f66 Binary files /dev/null and b/1ano/2semestre/c2/testes/2021-2022/moodle_t1_2122.pdf differ diff --git a/1ano/2semestre/c2/testes/2021-2022/moodle_t2_2122.pdf b/1ano/2semestre/c2/testes/2021-2022/moodle_t2_2122.pdf new file mode 100644 index 0000000..037b6eb Binary files /dev/null and b/1ano/2semestre/c2/testes/2021-2022/moodle_t2_2122.pdf differ diff --git a/1ano/2semestre/poo/README.md b/1ano/2semestre/poo/README.md index d0189bb..2188a49 100755 --- a/1ano/2semestre/poo/README.md +++ b/1ano/2semestre/poo/README.md @@ -11,15 +11,16 @@ --- ## Índice -| Aula nº | Tópicos | -|-----------------------------------------------------------------------------------------|----------------------| -| [01](https://github.com/TiagoRG/uaveiro-leci/tree/master/1ano/2semestre/poo/src/aula01) | Introduction, Basics | -| [02](https://github.com/TiagoRG/uaveiro-leci/tree/master/1ano/2semestre/poo/src/aula02) | Flux Control | -| [03](https://github.com/TiagoRG/uaveiro-leci/tree/master/1ano/2semestre/poo/src/aula03) | Classes | -| [04](https://github.com/TiagoRG/uaveiro-leci/tree/master/1ano/2semestre/poo/src/aula04) | Classes | -| [05](https://github.com/TiagoRG/uaveiro-leci/tree/master/1ano/2semestre/poo/src/aula05) | Classes | -| [06](https://github.com/TiagoRG/uaveiro-leci/tree/master/1ano/2semestre/poo/src/aula06) | Inheritance | -| [07](https://github.com/TiagoRG/uaveiro-leci/tree/master/1ano/2semestre/poo/src/aula07) | Polymorphism | +| Aula nº | Tópicos | +|-----------------------------------------------------------------------------------------|-------------------------| +| [01](https://github.com/TiagoRG/uaveiro-leci/tree/master/1ano/2semestre/poo/src/aula01) | Introduction, Basics | +| [02](https://github.com/TiagoRG/uaveiro-leci/tree/master/1ano/2semestre/poo/src/aula02) | Flux Control | +| [03](https://github.com/TiagoRG/uaveiro-leci/tree/master/1ano/2semestre/poo/src/aula03) | Classes | +| [04](https://github.com/TiagoRG/uaveiro-leci/tree/master/1ano/2semestre/poo/src/aula04) | Classes | +| [05](https://github.com/TiagoRG/uaveiro-leci/tree/master/1ano/2semestre/poo/src/aula05) | Classes | +| [06](https://github.com/TiagoRG/uaveiro-leci/tree/master/1ano/2semestre/poo/src/aula06) | Inheritance | +| [07](https://github.com/TiagoRG/uaveiro-leci/tree/master/1ano/2semestre/poo/src/aula07) | Polymorphism | +| [08](https://github.com/TiagoRG/uaveiro-leci/tree/master/1ano/2semestre/poo/src/aula08) | Interfaces, Collections | --- *Pode conter erros, caso encontre algum, crie um* [*ticket*](https://github.com/TiagoRG/uaveiro-leci/issues/new) diff --git a/1ano/2semestre/poo/src/README.md b/1ano/2semestre/poo/src/README.md index 6e6c929..e7a7bb8 100644 --- a/1ano/2semestre/poo/src/README.md +++ b/1ano/2semestre/poo/src/README.md @@ -3,15 +3,16 @@ ### Métodos extra no diretório [*utils*](https://github.com/TiagoRG/uaveiro-leci/tree/master/1ano/2semestre/poo/src/utils) ## Índice -| Aula nº | Tópicos | -|-----------------------------------------------------------------------------------------|----------------------| -| [01](https://github.com/TiagoRG/uaveiro-leci/tree/master/1ano/2semestre/poo/src/aula01) | Introduction, Basics | -| [02](https://github.com/TiagoRG/uaveiro-leci/tree/master/1ano/2semestre/poo/src/aula02) | Flux Control | -| [03](https://github.com/TiagoRG/uaveiro-leci/tree/master/1ano/2semestre/poo/src/aula03) | Classes | -| [04](https://github.com/TiagoRG/uaveiro-leci/tree/master/1ano/2semestre/poo/src/aula04) | Classes | -| [05](https://github.com/TiagoRG/uaveiro-leci/tree/master/1ano/2semestre/poo/src/aula05) | Classes | -| [06](https://github.com/TiagoRG/uaveiro-leci/tree/master/1ano/2semestre/poo/src/aula06) | Inheritance | -| [07](https://github.com/TiagoRG/uaveiro-leci/tree/master/1ano/2semestre/poo/src/aula07) | Polymorphism | +| Aula nº | Tópicos | +|-----------------------------------------------------------------------------------------|-------------------------| +| [01](https://github.com/TiagoRG/uaveiro-leci/tree/master/1ano/2semestre/poo/src/aula01) | Introduction, Basics | +| [02](https://github.com/TiagoRG/uaveiro-leci/tree/master/1ano/2semestre/poo/src/aula02) | Flux Control | +| [03](https://github.com/TiagoRG/uaveiro-leci/tree/master/1ano/2semestre/poo/src/aula03) | Classes | +| [04](https://github.com/TiagoRG/uaveiro-leci/tree/master/1ano/2semestre/poo/src/aula04) | Classes | +| [05](https://github.com/TiagoRG/uaveiro-leci/tree/master/1ano/2semestre/poo/src/aula05) | Classes | +| [06](https://github.com/TiagoRG/uaveiro-leci/tree/master/1ano/2semestre/poo/src/aula06) | Inheritance | +| [07](https://github.com/TiagoRG/uaveiro-leci/tree/master/1ano/2semestre/poo/src/aula07) | Polymorphism | +| [08](https://github.com/TiagoRG/uaveiro-leci/tree/master/1ano/2semestre/poo/src/aula08) | Interfaces, Collections | --- *Pode conter erros, caso encontre algum, crie um* [*ticket*](https://github.com/TiagoRG/uaveiro-leci/issues/new) diff --git a/1ano/2semestre/poo/src/aula01/README.md b/1ano/2semestre/poo/src/aula01/README.md index dae3ea4..c925d8e 100755 --- a/1ano/2semestre/poo/src/aula01/README.md +++ b/1ano/2semestre/poo/src/aula01/README.md @@ -3,7 +3,6 @@ ### Tópico principal da aula: Introduction, Basics * [Guião](https://github.com/TiagoRG/uaveiro-leci/tree/master/1ano/2semestre/poo/guides/POO-2021-aula01.pdf) -* [Slides](https://github.com/TiagoRG/uaveiro-leci/tree/master/1ano/2semestre/poo/slides/POO_01_Introdução.pdf) --- *Pode conter erros, caso encontre algum, crie um* [*ticket*](https://github.com/TiagoRG/uaveiro-leci/issues/new) diff --git a/1ano/2semestre/poo/src/aula02/README.md b/1ano/2semestre/poo/src/aula02/README.md index 5fdc3f6..272e561 100755 --- a/1ano/2semestre/poo/src/aula02/README.md +++ b/1ano/2semestre/poo/src/aula02/README.md @@ -3,8 +3,6 @@ ### Tópico principal da aula: Flux Control * [Guião](https://github.com/TiagoRG/uaveiro-leci/tree/master/1ano/2semestre/poo/guides/POO-2021-aula02.pdf) -* [Slides 1](https://github.com/TiagoRG/uaveiro-leci/tree/master/1ano/2semestre/poo/slides/POO_02_ControloFluxo.pdf) -* [Slides 2](https://github.com/TiagoRG/uaveiro-leci/tree/master/1ano/2semestre/poo/slides/POO_02_Modularidade_MetodosEstaticos.pdf) ### Exercise List | Exercise Number | File Name | Exercise Number | File Name | diff --git a/1ano/2semestre/poo/src/aula03/README.md b/1ano/2semestre/poo/src/aula03/README.md index 530859c..479b906 100755 --- a/1ano/2semestre/poo/src/aula03/README.md +++ b/1ano/2semestre/poo/src/aula03/README.md @@ -3,7 +3,6 @@ ### Tópico principal da aula: Classes * [Guião](https://github.com/TiagoRG/uaveiro-leci/tree/master/1ano/2semestre/poo/guides/POO-2021-aula03.pdf) -* [Slides](https://github.com/TiagoRG/uaveiro-leci/tree/master/1ano/2semestre/poo/slides/POO_03_Classes.pdf) ### Exercise List | Exercise Number | File Name | diff --git a/1ano/2semestre/poo/src/aula04/README.md b/1ano/2semestre/poo/src/aula04/README.md index 259b4c7..57befe6 100755 --- a/1ano/2semestre/poo/src/aula04/README.md +++ b/1ano/2semestre/poo/src/aula04/README.md @@ -3,7 +3,6 @@ ### Tópico principal da aula: Classes * [Guião](https://github.com/TiagoRG/uaveiro-leci/tree/master/1ano/2semestre/poo/guides/POO-2021-aula04.pdf) -* [Slides](https://github.com/TiagoRG/uaveiro-leci/tree/master/1ano/2semestre/poo/slides/POO_03_Classes.pdf) ### Exercise List | Exercise Number | File Name | diff --git a/1ano/2semestre/poo/src/aula05/README.md b/1ano/2semestre/poo/src/aula05/README.md index ef70d71..5c300b4 100755 --- a/1ano/2semestre/poo/src/aula05/README.md +++ b/1ano/2semestre/poo/src/aula05/README.md @@ -3,7 +3,6 @@ ### Tópico principal da aula: Classes * [Guião](https://github.com/TiagoRG/uaveiro-leci/tree/master/1ano/2semestre/poo/guides/POO-2022-aula05.pdf) -* [Slides](https://github.com/TiagoRG/uaveiro-leci/tree/master/1ano/2semestre/poo/slides/POO_03_Classes.pdf) ### Exercise List | Exercise Number | File Name | diff --git a/1ano/2semestre/poo/src/aula06/README.md b/1ano/2semestre/poo/src/aula06/README.md index ce22eae..bf20156 100755 --- a/1ano/2semestre/poo/src/aula06/README.md +++ b/1ano/2semestre/poo/src/aula06/README.md @@ -3,7 +3,6 @@ ### Tópico principal da aula: Inheritance * [Guião](https://github.com/TiagoRG/uaveiro-leci/tree/master/1ano/2semestre/poo/guides/POO-2022-aula06.pdf) -* [Slides](https://github.com/TiagoRG/uaveiro-leci/tree/master/1ano/2semestre/poo/slides/POO_04_Herança.pdf) ### Exercise List | Exercise Number | Files Name | diff --git a/1ano/2semestre/poo/src/aula07/README.md b/1ano/2semestre/poo/src/aula07/README.md index cad5775..b212d8e 100755 --- a/1ano/2semestre/poo/src/aula07/README.md +++ b/1ano/2semestre/poo/src/aula07/README.md @@ -3,7 +3,6 @@ ### Tópico principal da aula: Polymorphism * [Guião](https://github.com/TiagoRG/uaveiro-leci/tree/master/1ano/2semestre/poo/guides/POO-2022-aula07.pdf) -* [Slides](https://github.com/TiagoRG/uaveiro-leci/tree/master/1ano/2semestre/poo/slides/POO_05_Polimorfismo.pdf) ### Exercise List | Exercise Number | Files Name | diff --git a/1ano/2semestre/poo/src/aula08/README.md b/1ano/2semestre/poo/src/aula08/README.md new file mode 100755 index 0000000..1a9cfa3 --- /dev/null +++ b/1ano/2semestre/poo/src/aula08/README.md @@ -0,0 +1,58 @@ +# Programação Orientada a Objetos +## Aula 08 +### Tópico principal da aula: Interfaces, Collections + +* [Guião](https://github.com/TiagoRG/uaveiro-leci/tree/master/1ano/2semestre/poo/guides/POO-2022-aula08.pdf) + +### File List per Exercise + +#### Ex1 +* [Main.java](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex1/Main.java) +* [VehicleComp.java](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex1/VehicleComp.java) +* [Vehicles](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex1/Vehicles) + * [Vehicle.java](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex1/Vehicles/Vehicle.java) + * [Motorcycle.java](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex1/Vehicles/Motorcycle.java) + * [Car.java](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex1/Vehicles/Car.java) + * [Taxi.java](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex1/Vehicles/Taxi.java) + * [Bus.java](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex1/Vehicles/Bus.java) + * [Truck.java](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex1/Vehicles/Truck.java) +* [Interfaces](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex1/Interfaces) + * [IKmTravelled.java](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex1/Interfaces/IKmTravelled.java) + * [IFuelVehicle.java](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex1/Interfaces/IFuelVehicle.java) + * [IElectricVehicle.java](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex1/Interfaces/IElectricVehicle.java) +* [Enums](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex1/Enums) + * [EngineType.java](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex1/Enums/EngineType.java) + +#### Ex2 + +* [Main.java](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex2/Main.java) +* [Menu.java](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex2/Menu.java) +* [Aliments](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex2/Aliments) + * [Aliment.java](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex2/Aliments/Aliment.java) + * [Cereal.java](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex2/Aliments/Cereal.java) + * [Fish.java](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex2/Aliments/Fish.java) + * [Meat.java](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex2/Aliments/Meat.java) + * [Vegetable.java](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex2/Aliments/Vegetable.java) +* [Dishes](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex2/Dishes) + * [Dish.java](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex2/Dishes/Dish.java) + * [VeganDish.java](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex2/Dishes/VeganDish.java) + * [DietDish.java](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex2/Dishes/DietDish.java) +* [Enums](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex1/Enums) + * [AlimentOrigin.java](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex1/Enums/AlimentOrigin.java) + * [AlimentType.java](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex1/Enums/AlimentType.java) + * [DishType.java](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex1/Enums/DishType.java) + * [FishState.java](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex1/Enums/FishState.java) + * [MeatType.java](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex1/Enums/MeatType.java) + +#### Ex3 + +* [ShoppingCarTester.java](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex3/ShoppingCarTester.java) +* [Purchase.java](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex3/Purchase.java) +* [Product.java](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex3/Product.java) +* [PurchaseWithDiscount.java](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex3/PurchaseWithDiscount.java) +* [Interfaces](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex3/Interfaces) + * [IPurchase.java](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex3/Interfaces/IPurchase.java) + * [IProduct.java](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex3/Interfaces/IProduct.java) + +--- +*Pode conter erros, caso encontre algum, crie um* [*ticket*](https://github.com/TiagoRG/uaveiro-leci/issues/new) diff --git a/1ano/2semestre/poo/src/aula08/ex1/README.md b/1ano/2semestre/poo/src/aula08/ex1/README.md new file mode 100644 index 0000000..7ca3334 --- /dev/null +++ b/1ano/2semestre/poo/src/aula08/ex1/README.md @@ -0,0 +1,20 @@ +# Programação Orientada a Objetos +## Aula 08 - Exercise 1 + +### File list + +* [Main.java](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex1/Main.java) +* [VehicleComp.java](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex1/VehicleComp.java) +* [Vehicles](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex1/Vehicles) + * [Vehicle.java](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex1/Vehicles/Vehicle.java) + * [Motorcycle.java](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex1/Vehicles/Motorcycle.java) + * [Car.java](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex1/Vehicles/Car.java) + * [Taxi.java](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex1/Vehicles/Taxi.java) + * [Bus.java](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex1/Vehicles/Bus.java) + * [Truck.java](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex1/Vehicles/Truck.java) +* [Interfaces](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex1/Interfaces) + * [IKmTravelled.java](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex1/Interfaces/IKmTravelled.java) + * [IFuelVehicle.java](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex1/Interfaces/IFuelVehicle.java) + * [IElectricVehicle.java](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex1/Interfaces/IElectricVehicle.java) +* [Enums](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex1/Enums) + * [EngineType.java](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex1/Enums/EngineType.java) \ No newline at end of file diff --git a/1ano/2semestre/poo/src/aula08/ex1/Vehicles/Motorcycle.java b/1ano/2semestre/poo/src/aula08/ex1/Vehicles/Motorcycle.java index e50f3c7..fedac02 100644 --- a/1ano/2semestre/poo/src/aula08/ex1/Vehicles/Motorcycle.java +++ b/1ano/2semestre/poo/src/aula08/ex1/Vehicles/Motorcycle.java @@ -61,7 +61,7 @@ public class Motorcycle extends Vehicle implements IFuelVehicle { this.fuelLevel = level; } - enum MotorcycleType { + public enum MotorcycleType { SPORT, TOURING; public String toString() { diff --git a/1ano/2semestre/poo/src/aula08/ex2/Aliments/Aliment.java b/1ano/2semestre/poo/src/aula08/ex2/Aliments/Aliment.java new file mode 100644 index 0000000..72dcf1f --- /dev/null +++ b/1ano/2semestre/poo/src/aula08/ex2/Aliments/Aliment.java @@ -0,0 +1,66 @@ +package aula08.ex2.Aliments; + +import aula08.ex2.Enums.AlimentOrigin; + +import java.util.Objects; + +public abstract class Aliment { + double proteins; + double calories; + double weight; + final AlimentOrigin alimentOrigin; + + public Aliment(double proteins, double calories, double weight, AlimentOrigin alimentOrigin) { + setProteins(proteins); + setCalories(calories); + setCalories(weight); + this.alimentOrigin = alimentOrigin; + } + + public double getProteins() { + return this.proteins; + }; + + public void setProteins(double proteins) { + if (proteins <= 0) + throw new IllegalArgumentException("Proteins must be positive"); + this.proteins = proteins; + } + + public double getCalories() { + return this.calories; + } + + public void setCalories(double calories) { + if (calories <= 0) + throw new IllegalArgumentException("Calories must be positive"); + this.calories = calories; + } + + public double getWeight() { + return this.weight; + } + + public void setWeight(double weight) { + if (weight <= 0) + throw new IllegalArgumentException("Weight must be positive"); + this.weight = weight; + } + + public AlimentOrigin getAlimentOrigin() { + return this.alimentOrigin; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Aliment aliment = (Aliment) o; + return Double.compare(aliment.getProteins(), getProteins()) == 0 && Double.compare(aliment.getCalories(), getCalories()) == 0 && Double.compare(aliment.getWeight(), getWeight()) == 0 && getAlimentOrigin() == aliment.getAlimentOrigin(); + } + + @Override + public int hashCode() { + return Objects.hash(getProteins(), getCalories(), getWeight(), getAlimentOrigin()); + } +} diff --git a/1ano/2semestre/poo/src/aula08/ex2/Aliments/Cereal.java b/1ano/2semestre/poo/src/aula08/ex2/Aliments/Cereal.java new file mode 100644 index 0000000..2472bd3 --- /dev/null +++ b/1ano/2semestre/poo/src/aula08/ex2/Aliments/Cereal.java @@ -0,0 +1,37 @@ +package aula08.ex2.Aliments; + +import aula08.ex2.Enums.AlimentOrigin; + +import java.util.Objects; + +public class Cereal extends Aliment { + private final String name; + + public Cereal(String name, double proteins, double calories, double weight) { + super(proteins, calories, weight, AlimentOrigin.VEGAN); + this.name = name; + } + + public String getName() { + return this.name; + } + + @Override + public String toString() { + return String.format("Cereal %s, Proteins: %.1f, Calories: %.1f, Weight: %.1f", this.getName(), this.getProteins(), this.getCalories(), this.getWeight()); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + if (!super.equals(o)) return false; + Cereal cereal = (Cereal) o; + return getName().equals(cereal.getName()); + } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode(), getName()); + } +} diff --git a/1ano/2semestre/poo/src/aula08/ex2/Aliments/Fish.java b/1ano/2semestre/poo/src/aula08/ex2/Aliments/Fish.java new file mode 100644 index 0000000..24b67e6 --- /dev/null +++ b/1ano/2semestre/poo/src/aula08/ex2/Aliments/Fish.java @@ -0,0 +1,42 @@ +package aula08.ex2.Aliments; + +import aula08.ex2.Enums.AlimentOrigin; +import aula08.ex2.Enums.FishState; + +import java.util.Objects; + +public class Fish extends Aliment { + private FishState fishState; + + public Fish(FishState fishState, double proteins, double calories, double weight) { + super(proteins, calories, weight, AlimentOrigin.ANIMAL); + this.fishState = fishState; + } + + public FishState getFishState() { + return this.fishState; + } + + public void setFishState(FishState fishState) { + this.fishState = fishState; + } + + @Override + public String toString() { + return String.format("Fish %s, Proteins: %.1f, Calories: %.1f, Weight: %.1f", this.getFishState().toString(), this.getProteins(), this.getCalories(), this.getWeight()); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + if (!super.equals(o)) return false; + Fish fish = (Fish) o; + return getFishState() == fish.getFishState(); + } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode(), getFishState()); + } +} diff --git a/1ano/2semestre/poo/src/aula08/ex2/Aliments/Meat.java b/1ano/2semestre/poo/src/aula08/ex2/Aliments/Meat.java new file mode 100644 index 0000000..47eeb2c --- /dev/null +++ b/1ano/2semestre/poo/src/aula08/ex2/Aliments/Meat.java @@ -0,0 +1,42 @@ +package aula08.ex2.Aliments; + +import aula08.ex2.Enums.AlimentOrigin; +import aula08.ex2.Enums.MeatType; + +import java.util.Objects; + +public class Meat extends Aliment { + private MeatType meatType; + + public Meat(MeatType meatType, double proteins, double calories, double weight) { + super(proteins, calories, weight, AlimentOrigin.ANIMAL); + setMeatType(meatType); + } + + public MeatType getMeatType() { + return this.meatType; + } + + public void setMeatType(MeatType meatType) { + this.meatType = meatType; + } + + @Override + public String toString() { + return String.format("Meat %s, Proteins: %.1f, Calories: %.1f, Weight: %.1f", this.getMeatType().toString(), this.getProteins(), this.getCalories(), this.getWeight()); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + if (!super.equals(o)) return false; + Meat meat = (Meat) o; + return getMeatType() == meat.getMeatType(); + } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode(), getMeatType()); + } +} diff --git a/1ano/2semestre/poo/src/aula08/ex2/Aliments/Vegetable.java b/1ano/2semestre/poo/src/aula08/ex2/Aliments/Vegetable.java new file mode 100644 index 0000000..3bd5225 --- /dev/null +++ b/1ano/2semestre/poo/src/aula08/ex2/Aliments/Vegetable.java @@ -0,0 +1,37 @@ +package aula08.ex2.Aliments; + +import aula08.ex2.Enums.AlimentOrigin; + +import java.util.Objects; + +public class Vegetable extends Aliment { + private final String name; + + public Vegetable(String name, double proteins, double calories, double weight) { + super(proteins, calories, weight, AlimentOrigin.VEGAN); + this.name = name; + } + + public String getName() { + return this.name; + } + + @Override + public String toString() { + return String.format("Vegetable %s, Proteins: %.1f, Calories: %.1f, Weight: %.1f", this.getName(), this.getProteins(), this.getCalories(), this.getWeight()); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + if (!super.equals(o)) return false; + Vegetable vegetable = (Vegetable) o; + return getName().equals(vegetable.getName()); + } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode(), getName()); + } +} diff --git a/1ano/2semestre/poo/src/aula08/ex2/Dishes/DietDish.java b/1ano/2semestre/poo/src/aula08/ex2/Dishes/DietDish.java new file mode 100644 index 0000000..3558e5b --- /dev/null +++ b/1ano/2semestre/poo/src/aula08/ex2/Dishes/DietDish.java @@ -0,0 +1,40 @@ +package aula08.ex2.Dishes; + +import aula08.ex2.Aliments.Aliment; + +import java.util.Objects; + +public class DietDish extends Dish { + private final double maxCalories; + + public DietDish(String name, double maxCalories) { + super(name); + this.maxCalories = maxCalories; + } + + @Override + public void addAliment(Aliment aliment) { + if (aliment.getCalories() > (maxCalories - this.calculateCalories())) + throw new IllegalArgumentException("Aliment is over calories limit."); + super.addAliment(aliment); + } + + @Override + public String toString() { + return String.format("Dish '%s', using %d aliments - Diet (%.1f calories)", this.getName(), this.getAlimentCount(), this.calculateCalories()); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + if (!super.equals(o)) return false; + DietDish dietDish = (DietDish) o; + return Double.compare(dietDish.maxCalories, maxCalories) == 0; + } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode(), maxCalories); + } +} diff --git a/1ano/2semestre/poo/src/aula08/ex2/Dishes/Dish.java b/1ano/2semestre/poo/src/aula08/ex2/Dishes/Dish.java new file mode 100644 index 0000000..327f113 --- /dev/null +++ b/1ano/2semestre/poo/src/aula08/ex2/Dishes/Dish.java @@ -0,0 +1,70 @@ +package aula08.ex2.Dishes; + +import aula08.ex2.Aliments.Aliment; +import java.util.LinkedList; +import java.util.Objects; + +public class Dish { + private final String name; + private final LinkedList aliments; + + public Dish(String name) { + this.name = name; + this.aliments = new LinkedList<>(); + } + + public String getName() { + return name; + } + + public LinkedList getAliments() { + return this.aliments; + } + + public void addAliment(Aliment aliment) { + this.aliments.add(aliment); + } + + public int getAlimentCount() { + return this.aliments.size(); + } + + public double calculateCalories() { + double total = 0; + for (Aliment aliment : this.aliments) + total += aliment.getCalories(); + return total; + } + + public double calculateProteins() { + double total = 0; + for (Aliment aliment : this.aliments) + total += aliment.getProteins(); + return total; + } + + public double calculateWeight() { + double total = 0; + for (Aliment aliment : this.aliments) + total += aliment.getWeight(); + return total; + } + + @Override + public String toString() { + return String.format("Dish '%s', using %d aliments", this.getName(), this.getAlimentCount()); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Dish dish = (Dish) o; + return getName().equals(dish.getName()) && getAliments().equals(dish.getAliments()); + } + + @Override + public int hashCode() { + return Objects.hash(getName(), getAliments()); + } +} diff --git a/1ano/2semestre/poo/src/aula08/ex2/Dishes/VeganDish.java b/1ano/2semestre/poo/src/aula08/ex2/Dishes/VeganDish.java new file mode 100644 index 0000000..347b200 --- /dev/null +++ b/1ano/2semestre/poo/src/aula08/ex2/Dishes/VeganDish.java @@ -0,0 +1,22 @@ +package aula08.ex2.Dishes; + +import aula08.ex2.Aliments.Aliment; +import aula08.ex2.Enums.AlimentOrigin; + +public class VeganDish extends Dish { + public VeganDish(String name) { + super(name); + } + + @Override + public void addAliment(Aliment aliment) { + if (aliment.getAlimentOrigin() == AlimentOrigin.ANIMAL) + throw new IllegalArgumentException("Aliment must be vegan."); + super.addAliment(aliment); + } + + @Override + public String toString() { + return String.format("Dish '%s', using %d aliments - Vegan dish", this.getName(), this.getAlimentCount()); + } +} diff --git a/1ano/2semestre/poo/src/aula08/ex2/Enums/AlimentOrigin.java b/1ano/2semestre/poo/src/aula08/ex2/Enums/AlimentOrigin.java new file mode 100644 index 0000000..a4c4ce3 --- /dev/null +++ b/1ano/2semestre/poo/src/aula08/ex2/Enums/AlimentOrigin.java @@ -0,0 +1,13 @@ +package aula08.ex2.Enums; + +public enum AlimentOrigin { + ANIMAL, VEGAN; + + @Override + public String toString() { + return switch (this) { + case ANIMAL -> "ANIMAL"; + case VEGAN -> "VEGAN"; + }; + } +} diff --git a/1ano/2semestre/poo/src/aula08/ex2/Enums/AlimentType.java b/1ano/2semestre/poo/src/aula08/ex2/Enums/AlimentType.java new file mode 100644 index 0000000..5bfc701 --- /dev/null +++ b/1ano/2semestre/poo/src/aula08/ex2/Enums/AlimentType.java @@ -0,0 +1,25 @@ +package aula08.ex2.Enums; + +public enum AlimentType { + MEAT, FISH, CEREAL, VEGETABLE; + + public static AlimentType fromString(String string) { + return switch (string) { + case "MEAT", "Meat", "meat" -> MEAT; + case "FISH", "Fish", "fish" -> FISH; + case "CEREAL", "Cereal", "cereal" -> CEREAL; + case "VEGETABLE", "Vegetable", "vegetable" -> VEGETABLE; + default -> null; + }; + } + + @Override + public String toString() { + return switch (this) { + case MEAT -> "Meat"; + case FISH -> "Fish"; + case CEREAL -> "Cereal"; + case VEGETABLE -> "Vegetable"; + }; + } +} diff --git a/1ano/2semestre/poo/src/aula08/ex2/Enums/DishType.java b/1ano/2semestre/poo/src/aula08/ex2/Enums/DishType.java new file mode 100644 index 0000000..90098e5 --- /dev/null +++ b/1ano/2semestre/poo/src/aula08/ex2/Enums/DishType.java @@ -0,0 +1,23 @@ +package aula08.ex2.Enums; + +public enum DishType { + NORMAL, VEGAN, DIET; + + public static DishType fromString(String string) { + return switch (string) { + case "NORMAL", "Normal", "normal" -> NORMAL; + case "VEGAN", "Vegan", "vegan" -> VEGAN; + case "DIET", "Diet", "diet" -> DIET; + default -> null; + }; + } + + @Override + public String toString() { + return switch (this) { + case NORMAL -> "NORMAL"; + case VEGAN -> "VEGAN"; + case DIET -> "DIET"; + }; + } +} diff --git a/1ano/2semestre/poo/src/aula08/ex2/Enums/FishState.java b/1ano/2semestre/poo/src/aula08/ex2/Enums/FishState.java new file mode 100644 index 0000000..ee33518 --- /dev/null +++ b/1ano/2semestre/poo/src/aula08/ex2/Enums/FishState.java @@ -0,0 +1,21 @@ +package aula08.ex2.Enums; + +public enum FishState { + FRESH, FROZEN; + + public static FishState fromString(String string) { + return switch (string) { + case "FRESH", "Fresh", "fresh" -> FRESH; + case "FROZEN", "Frozen", "frozen" -> FROZEN; + default -> null; + }; + } + + @Override + public String toString() { + return switch (this) { + case FRESH -> "FRESH"; + case FROZEN -> "FROZEN"; + }; + } +} diff --git a/1ano/2semestre/poo/src/aula08/ex2/Enums/MeatType.java b/1ano/2semestre/poo/src/aula08/ex2/Enums/MeatType.java new file mode 100644 index 0000000..73709d6 --- /dev/null +++ b/1ano/2semestre/poo/src/aula08/ex2/Enums/MeatType.java @@ -0,0 +1,25 @@ +package aula08.ex2.Enums; + +public enum MeatType { + COW, PORK, TURKEY, CHICKEN; + + public static MeatType fromString(String string) { + return switch (string) { + case "COW", "Cow", "cow" -> COW; + case "PORK", "Pork", "pork" -> PORK; + case "TURKEY", "Turkey", "turkey" -> TURKEY; + case "CHICKEN", "Chicken", "chicken" -> CHICKEN; + default -> null; + }; + } + + @Override + public String toString() { + return switch (this) { + case COW -> "COW"; + case PORK -> "PORK"; + case TURKEY -> "TURKEY"; + case CHICKEN -> "CHICKEN"; + }; + } +} diff --git a/1ano/2semestre/poo/src/aula08/ex2/Main.java b/1ano/2semestre/poo/src/aula08/ex2/Main.java new file mode 100644 index 0000000..8ba6d41 --- /dev/null +++ b/1ano/2semestre/poo/src/aula08/ex2/Main.java @@ -0,0 +1,27 @@ +package aula08.ex2; + +import java.util.LinkedList; +import java.util.Scanner; + +public class Main { + private static final Scanner sin = new Scanner(System.in); + private static LinkedList Menus; + + public static void main(String[] args) { + while (true) { + System.out.print("Choose an option:\n1 - Create menu\n2 - List menus\n0 - Exit\n\n>> "); + int option = Integer.parseInt(sin.nextLine()); + switch (option) { + case 0 -> { + sin.close(); + System.exit(0); + } + case 1 -> Menus.add(new Menu(sin)); + case 2 -> { + for (Menu menu : Menus) + System.out.println(menu); + } + } + } + } +} diff --git a/1ano/2semestre/poo/src/aula08/ex2/Menu.java b/1ano/2semestre/poo/src/aula08/ex2/Menu.java new file mode 100644 index 0000000..1af5082 --- /dev/null +++ b/1ano/2semestre/poo/src/aula08/ex2/Menu.java @@ -0,0 +1,131 @@ +package aula08.ex2; + +import aula08.ex2.Aliments.*; +import aula08.ex2.Dishes.*; +import aula08.ex2.Enums.*; +import utils.Enums.Weekday; + +import java.util.LinkedHashMap; +import java.util.Scanner; + +public class Menu { + private final Scanner sin; + private final LinkedHashMap menu; + + public Menu(Scanner sin, LinkedHashMap menu) { + this.sin = sin; + this.menu = menu; + while (true) { + System.out.print("Choose an option:\n1 - Add dish\n2 - Remove dish\n3 - Print menu\n0 - Exit\n\n>> "); + int option = Integer.parseInt(sin.nextLine()); + switch (option) { + case 0 -> { + return; + } + case 1 -> { + System.out.print("What weekday do you want to add a dish to: "); + Weekday weekday = Weekday.fromString(sin.nextLine()); + if (this.menu.containsKey(weekday)) + System.out.print("That weekday already has a dish assigned to it."); + else + this.menu.put(weekday, this.dishBuilder()); + } + case 2 -> { + System.out.print("What weekday dish do you want to remove: "); + Weekday weekday = Weekday.fromString(sin.nextLine()); + try { + this.menu.remove(weekday); + } catch (Exception ignored) { + System.out.println("That weekday has no dish assigned to."); + } + } + case 3 -> System.out.println(this); + default -> System.out.println("Invalid option."); + } + } + } + + public Menu(Scanner sin) { + this(sin, new LinkedHashMap<>()); + } + + public Menu() { + this(new Scanner(System.in), new LinkedHashMap<>()); + } + + public Dish dishBuilder() { + System.out.print("Dish name: "); + String name = sin.nextLine(); + Dish dish; + while (true) { + System.out.print("Dish type? (NORMAL/VEGAN/DIET): "); + DishType dishType = DishType.fromString(sin.nextLine()); + switch (dishType) { + case NORMAL -> dish = new Dish(name); + case VEGAN -> dish = new VeganDish(name); + case DIET -> { + System.out.print("Calories limit: "); + double caloriesLimit = Double.parseDouble(sin.nextLine()); + dish = new DietDish(name, caloriesLimit); + } + default -> { + System.out.print("Invalid option."); + continue; + } + } + break; + } + while (true) { + System.out.print("Choose an option:\n1 - Add aliment\n2 - Print dish\n0 - Finish dish\n\n>> "); + int option = Integer.parseInt(sin.nextLine()); + switch (option) { + case 0 -> { + return dish; + } + case 1 -> { + Aliment aliment = null; + System.out.print("Aliment calories: "); + double calories = Double.parseDouble(sin.nextLine()); + System.out.print("Aliment proteins: "); + double proteins = Double.parseDouble(sin.nextLine()); + System.out.print("Aliment weight: "); + double weight = Double.parseDouble(sin.nextLine()); + System.out.print("What type of aliment are u adding? (MEAT/FISH/CEREAL/VEGETABLE): "); + AlimentType alimentType = AlimentType.fromString(sin.nextLine()); + switch (alimentType) { + case MEAT -> { + System.out.print(alimentType + " type? (COW/PORK/TURKEY/CHICKEN): "); + MeatType meatType = MeatType.fromString(sin.nextLine()); + aliment = new Meat(meatType, proteins, calories, weight); + } + case FISH -> { + System.out.print(alimentType + " state? (FRESH/FROZEN): "); + FishState fishState = FishState.fromString(sin.nextLine()); + aliment = new Fish(fishState, proteins, calories, weight); + } + case CEREAL, VEGETABLE -> { + System.out.print(alimentType + " name: "); + String alimentName = sin.nextLine(); + aliment = alimentType == AlimentType.CEREAL ? new Cereal(alimentName, proteins, calories, weight) : new Vegetable(alimentName, proteins, calories, weight); + } + } + dish.addAliment(aliment); + } + case 2 -> { + System.out.println(dish); + for (Aliment aliment : dish.getAliments()) + System.out.println(aliment); + } + default -> System.out.println("Invalid option."); + } + } + } + + @Override + public String toString() { + StringBuilder string = new StringBuilder("Menu"); + for (Weekday weekDay : this.menu.keySet()) + string.append(String.format("%s : %s", weekDay, menu.get(weekDay))); + return string.toString(); + } +} diff --git a/1ano/2semestre/poo/src/aula08/ex2/README.md b/1ano/2semestre/poo/src/aula08/ex2/README.md new file mode 100644 index 0000000..2136a69 --- /dev/null +++ b/1ano/2semestre/poo/src/aula08/ex2/README.md @@ -0,0 +1,23 @@ +# Programação Orientada a Objetos +## Aula 08 - Exercise 2 + +### File list + +* [Main.java](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex2/Main.java) +* [Menu.java](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex2/Menu.java) +* [Aliments](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex2/Aliments) + * [Aliment.java](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex2/Aliments/Aliment.java) + * [Cereal.java](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex2/Aliments/Cereal.java) + * [Fish.java](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex2/Aliments/Fish.java) + * [Meat.java](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex2/Aliments/Meat.java) + * [Vegetable.java](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex2/Aliments/Vegetable.java) +* [Dishes](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex2/Dishes) + * [Dish.java](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex2/Dishes/Dish.java) + * [VeganDish.java](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex2/Dishes/VeganDish.java) + * [DietDish.java](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex2/Dishes/DietDish.java) +* [Enums](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex1/Enums) + * [AlimentOrigin.java](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex1/Enums/AlimentOrigin.java) + * [AlimentType.java](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex1/Enums/AlimentType.java) + * [DishType.java](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex1/Enums/DishType.java) + * [FishState.java](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex1/Enums/FishState.java) + * [MeatType.java](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex1/Enums/MeatType.java) \ No newline at end of file diff --git a/1ano/2semestre/poo/src/aula08/ex3/Interfaces/IProduct.java b/1ano/2semestre/poo/src/aula08/ex3/Interfaces/IProduct.java new file mode 100644 index 0000000..976274b --- /dev/null +++ b/1ano/2semestre/poo/src/aula08/ex3/Interfaces/IProduct.java @@ -0,0 +1,10 @@ +package aula08.ex3.Interfaces; + +public interface IProduct { + String getName(); + void setPrice(double price); + double getPrice(); + int stock(); + void addStock(int amount); + void removeStock(int amount); +} diff --git a/1ano/2semestre/poo/src/aula08/ex3/Interfaces/IPurchase.java b/1ano/2semestre/poo/src/aula08/ex3/Interfaces/IPurchase.java new file mode 100644 index 0000000..f9a007c --- /dev/null +++ b/1ano/2semestre/poo/src/aula08/ex3/Interfaces/IPurchase.java @@ -0,0 +1,9 @@ +package aula08.ex3.Interfaces; + +import aula08.ex3.Product; + +public interface IPurchase { + void addProduct(Product product, int amount); + void listProducts(); + double getTotal(); +} diff --git a/1ano/2semestre/poo/src/aula08/ex3/Product.java b/1ano/2semestre/poo/src/aula08/ex3/Product.java new file mode 100644 index 0000000..03ed778 --- /dev/null +++ b/1ano/2semestre/poo/src/aula08/ex3/Product.java @@ -0,0 +1,52 @@ +package aula08.ex3; + +import aula08.ex3.Interfaces.IProduct; + +public class Product implements IProduct { + private final String name; + private double price; + private int stock = 0; + + public Product(String name, double price, int stock) { + this.name = name; + this.setPrice(price); + this.addStock(stock); + } + + @Override + public String getName() { + return this.name; + } + + @Override + public double getPrice() { + return this.price; + } + + @Override + public void setPrice(double price) { + if (price <= 0) + throw new IllegalArgumentException("Price must be positive."); + this.price = price; + } + + @Override + public int stock() { + return this.stock; + } + + @Override + public void addStock(int amount) { + this.stock += amount; + } + + @Override + public void removeStock(int amount) { + this.stock -= amount; + } + + @Override + public String toString() { + return String.format("Product: %s\n\tStock: %d\n\tPrice: %.2f\n", this.getName(), this.stock(), this.getPrice()); + } +} diff --git a/1ano/2semestre/poo/src/aula08/ex3/ProductWithDiscount.java b/1ano/2semestre/poo/src/aula08/ex3/ProductWithDiscount.java new file mode 100644 index 0000000..70e28e2 --- /dev/null +++ b/1ano/2semestre/poo/src/aula08/ex3/ProductWithDiscount.java @@ -0,0 +1,23 @@ +package aula08.ex3; + +public class ProductWithDiscount extends Product { + private double discountPercentage; + + public ProductWithDiscount(String name, double price, int stock, double discountPercentage) { + super(name, price, stock); + this.discountPercentage = discountPercentage; + } + + public double getDiscountPercentage() { + return this.discountPercentage; + } + + public void setDiscountPercentage(double discountPercentage) { + this.discountPercentage = discountPercentage; + } + + @Override + public double getPrice() { + return super.getPrice() * (1 - discountPercentage / 100); + } +} diff --git a/1ano/2semestre/poo/src/aula08/ex3/Purchase.java b/1ano/2semestre/poo/src/aula08/ex3/Purchase.java new file mode 100644 index 0000000..d6a1afb --- /dev/null +++ b/1ano/2semestre/poo/src/aula08/ex3/Purchase.java @@ -0,0 +1,36 @@ +package aula08.ex3; + +import aula08.ex3.Interfaces.IPurchase; +import java.util.LinkedHashMap; + +public class Purchase implements IPurchase { + private final LinkedHashMap products = new LinkedHashMap<>(); + + @Override + public void addProduct(Product product, int amount) { + if (product.stock() < amount) + amount = product.stock(); + product.removeStock(amount); + if (products.containsKey(product)) { + int currentAmount = products.get(product); + products.replace(product, currentAmount+amount); + } else + products.put(product, amount); + } + + @Override + public void listProducts() { + for (Product product : products.keySet()) { + int productAmount = products.get(product); + System.out.printf("Product: %s\n\tAmount: %d\n\tPrice: %.2f\n", product.getName(), productAmount, productAmount * product.getPrice()); + } + } + + @Override + public double getTotal() { + double total = 0; + for (Product product : products.keySet()) + total += product.getPrice() * products.get(product); + return total; + } +} diff --git a/1ano/2semestre/poo/src/aula08/ex3/README.md b/1ano/2semestre/poo/src/aula08/ex3/README.md new file mode 100644 index 0000000..cc03ada --- /dev/null +++ b/1ano/2semestre/poo/src/aula08/ex3/README.md @@ -0,0 +1,12 @@ +# Programação Orientada a Objetos +## Aula 08 - Exercise 3 + +### File list + +* [ShoppingCarTester.java](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex3/ShoppingCarTester.java) +* [Purchase.java](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex3/Purchase.java) +* [Product.java](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex3/Product.java) +* [PurchaseWithDiscount.java](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex3/PurchaseWithDiscount.java) +* [Interfaces](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex3/Interfaces) + * [IPurchase.java](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex3/Interfaces/IPurchase.java) + * [IProduct.java](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/poo/src/aula08/ex3/Interfaces/IProduct.java) diff --git a/1ano/2semestre/poo/src/aula08/ex3/ShoppingCartTester.java b/1ano/2semestre/poo/src/aula08/ex3/ShoppingCartTester.java index 522e606..f8ab88f 100644 --- a/1ano/2semestre/poo/src/aula08/ex3/ShoppingCartTester.java +++ b/1ano/2semestre/poo/src/aula08/ex3/ShoppingCartTester.java @@ -2,18 +2,18 @@ package aula08.ex3; public class ShoppingCartTester { public static void main(String[] args) { - /*Produto p1 = new ProdutoGenerico("Camisolas", 10, 3); - Produto p2 = new ProdutoGenerico("Calças", 30, 1); - Produto p3 = new ProdutoComDesconto("Sapatilhas", 50, 2, 50); - Produto p4 = new ProdutoComDesconto("Casacos", 100, 1, 10); + Product p1 = new Product("Camisolas", 10, 3); + Product p2 = new Product("Calças", 30, 1); + Product p3 = new ProductWithDiscount("Sapatilhas", 50, 2, 50); + Product p4 = new ProductWithDiscount("Casacos", 100, 1, 10); - CarrinhoDeCompras carrinho = new CarrinhoDeCompras(); - carrinho.adicionarProduto(p1, 1); - carrinho.adicionarProduto(p2, 5); - carrinho.adicionarProduto(p3, 2); - carrinho.adicionarProduto(p4, 1); + Purchase compra = new Purchase(); + compra.addProduct(p2, 5); + compra.addProduct(p3, 2); + compra.addProduct(p4, 1); + compra.addProduct(p1, 1); - carrinho.listarProdutos(); - System.out.printf("Preço total da compra %.2f\n", carrinho.calcularTotal());*/ + compra.listProducts(); + System.out.printf("Preço total da compra %.2f\n", compra.getTotal()); } } diff --git a/1ano/2semestre/poo/src/aval/aa1/Animal.java b/1ano/2semestre/poo/src/aval/aa1/Animal.java new file mode 100644 index 0000000..7fc1bd6 --- /dev/null +++ b/1ano/2semestre/poo/src/aval/aa1/Animal.java @@ -0,0 +1,76 @@ +package aval.aa1; + +import java.util.Objects; + +public class Animal { + public static int currentId = 1; + private final int id; + private String name; + private int weight; + private int age; + private String sponsor; + + public Animal(String name, int weight, int age, String sponsor) { + this.id = Animal.currentId++; + this.name = name; + this.weight = weight; + this.age = age; + this.sponsor = sponsor; + } + + public Animal(String name, int weight, int age) { + this(name, weight, age, null); + } + + public int getId() { + return id; + } + + public void setName(String name) { + this.name = name; + } + public String getName() { + return name; + } + + public void setWeight(int weight) { + if (weight <= 0) + throw new IllegalArgumentException("Weight must be positive!"); + this.weight = weight; + } + public int getWeight() { + return weight; + } + + public void setAge(int age) { + if (age <= 0) + throw new IllegalArgumentException("Age must be positive!"); + this.age = age; + } + public int getAge() { + return age; + } + + public void setSponsor(String sponsor) { + this.sponsor = sponsor; + } + public String getSponsor() { + return sponsor; + } + + @Override + public String toString() { + return String.format("ID: %d\nName: %s\nAge: %d\nWeight: %d\nSponsor: %s", this.id, this.name, this.age, this.weight, this.sponsor == null ? "None" : sponsor); + } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Animal animal = (Animal) o; + return id == animal.id && weight == animal.weight && age == animal.age && Objects.equals(name, animal.name) && Objects.equals(sponsor, animal.sponsor); + } + @Override + public int hashCode() { + return Objects.hash(id, name, weight, age, sponsor); + } +} diff --git a/1ano/2semestre/poo/src/aval/aa1/Bird.java b/1ano/2semestre/poo/src/aval/aa1/Bird.java new file mode 100644 index 0000000..02abeb9 --- /dev/null +++ b/1ano/2semestre/poo/src/aval/aa1/Bird.java @@ -0,0 +1,44 @@ +package aval.aa1; + +import java.util.Objects; + +public class Bird extends Animal { + private String habitat; + + public Bird(String name, int weight, int age, String habitat, String sponsor) { + super(name, weight, age, sponsor); + this.habitat = habitat; + } + + public Bird(String name, int weight, int age, String habitat) { + super(name, weight, age); + this.habitat = habitat; + } + + public String gethabitat() { + return this.habitat; + } + + public void sethabitat(String habitat) { + this.habitat = habitat; + } + + @Override + public String toString() { + return "Bird of habitat " + habitat + "\n" + super.toString(); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + if (!super.equals(o)) return false; + Bird bird = (Bird) o; + return Objects.equals(habitat, bird.habitat); + } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode(), habitat); + } +} diff --git a/1ano/2semestre/poo/src/aval/aa1/Dog.java b/1ano/2semestre/poo/src/aval/aa1/Dog.java new file mode 100644 index 0000000..1cd5962 --- /dev/null +++ b/1ano/2semestre/poo/src/aval/aa1/Dog.java @@ -0,0 +1,40 @@ +package aval.aa1; + +import java.util.Objects; + +public class Dog extends Animal { + private final String breed; + + public Dog(String name, int weight, int age, String breed, String sponsor) { + super(name, weight, age, sponsor); + this.breed = breed; + } + + public Dog(String name, int weight, int age, String breed) { + super(name, weight, age); + this.breed = breed; + } + + public String getBreed() { + return this.breed; + } + + @Override + public String toString() { + return "Dog of breed " + this.breed + "\n" + super.toString(); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + if (!super.equals(o)) return false; + Dog dog = (Dog) o; + return Objects.equals(breed, dog.breed); + } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode(), breed); + } +} diff --git a/1ano/2semestre/poo/src/aval/aa1/IPetShelter.java b/1ano/2semestre/poo/src/aval/aa1/IPetShelter.java new file mode 100644 index 0000000..f9cd0af --- /dev/null +++ b/1ano/2semestre/poo/src/aval/aa1/IPetShelter.java @@ -0,0 +1,9 @@ +package aval.aa1; + +public interface IPetShelter { + public void addAnimal(Animal animal); + public void removeAnimal(Animal animal); + public Animal searchForAnimal(String name); + public boolean sponsorAnimal(int animalId); + public void listAllAnimals(); +} diff --git a/1ano/2semestre/poo/src/aval/aa1/Main.java b/1ano/2semestre/poo/src/aval/aa1/Main.java new file mode 100644 index 0000000..564ff3f --- /dev/null +++ b/1ano/2semestre/poo/src/aval/aa1/Main.java @@ -0,0 +1,104 @@ +package aval.aa1; + +import java.util.Scanner; + +public class Main { + + public static void main(String[] args) { + Scanner scanner = new Scanner(System.in); + IPetShelter shelter = new PetShelter("Patudos"); + + int choice = 0; + do { + System.out.println("Choose an option:"); + System.out.println("1. Add animal"); + System.out.println("2. Remove animal"); + System.out.println("3. Search for animal"); + System.out.println("4. Sponsor an animal"); + System.out.println("5. View all animals"); + System.out.println("6. Exit"); + + choice = Integer.parseInt(scanner.nextLine()); + + switch (choice) { + case 1: + // adicionar animal + System.out.println("Adding an animal."); + System.out.print("Animal type (Dog/Rabbit/Bird): "); + String newAnimalType = scanner.nextLine(); + System.out.print("Animal name: "); + String newAnimalName = scanner.nextLine(); + System.out.print("Animal age: "); + int newAnimalAge = Integer.parseInt(scanner.nextLine()); + System.out.print("Animal weight: "); + int newAnimalWeight = Integer.parseInt(scanner.nextLine()); + System.out.print("Animal sponsor: "); + String newAnimalSponsor = scanner.nextLine(); + Animal newAnimal; + switch (newAnimalType) { + case "Dog": + System.out.print("Dog breed: "); + String breed = scanner.nextLine(); + newAnimal = new Dog(newAnimalName, newAnimalWeight, newAnimalAge, breed, newAnimalSponsor); + shelter.addAnimal(newAnimal); + break; + case "Rabbit": + System.out.print("Rabbit fur size (small/large): "); + String fur = scanner.nextLine(); + newAnimal = new Rabbit(newAnimalName, newAnimalWeight, newAnimalAge, fur, newAnimalSponsor); + shelter.addAnimal(newAnimal); + break; + case "Bird": + System.out.print("Bird habitat: "); + String habitat = scanner.nextLine(); + newAnimal = new Bird(newAnimalName, newAnimalWeight, newAnimalAge, habitat, newAnimalSponsor); + shelter.addAnimal(newAnimal); + break; + default: + System.out.println("Invalid animal."); + break; + } + break; + case 2: + // remover animal + System.out.print("Animal name: "); + String removedAnimalName = scanner.nextLine(); + Animal removedAnimal = shelter.searchForAnimal(removedAnimalName); + if (removedAnimal != null) { + shelter.removeAnimal(removedAnimal); + System.out.println("Animal removed."); + } else { + System.out.println("Animal not found."); + } + break; + case 3: + // procurar animal + System.out.print("Animal name:"); + String searchAnimalName = scanner.nextLine(); + System.out.println(shelter.searchForAnimal(searchAnimalName)); + break; + case 4: + // apadrinhar animal + System.out.print("Id of animal you want to sponsor: "); + int sponsorId = Integer.parseInt(scanner.nextLine()); + if (shelter.sponsorAnimal(sponsorId)) + System.out.println("Animal of id '" + sponsorId + "' was sponsored"); + else + System.out.println("Couldn't sponsor animal with id: " + sponsorId); + break; + case 5: + // imprimir a informação de todos os animais + shelter.listAllAnimals(); + break; + case 6: + System.out.println("Goodbye!"); + break; + default: + // imprimir mensagem de erro + System.out.println("Invalid option."); + break; + } + + } while (choice != 6); + } +} diff --git a/1ano/2semestre/poo/src/aval/aa1/PetShelter.java b/1ano/2semestre/poo/src/aval/aa1/PetShelter.java new file mode 100644 index 0000000..594a265 --- /dev/null +++ b/1ano/2semestre/poo/src/aval/aa1/PetShelter.java @@ -0,0 +1,67 @@ +package aval.aa1; + +import java.util.Scanner; + +public class PetShelter implements IPetShelter { + private String shelterName; + private Animal[] animals; + + public PetShelter(String shelterName) { + this.shelterName = shelterName; + } + + @Override + public void addAnimal(Animal animal) { + if (animals == null) { + animals = new Animal[1]; + animals[0] = animal; + } else { + Animal[] newAnimals = new Animal[animals.length + 1]; + for (int i = 0; i < animals.length; i++) { + newAnimals[i] = animals[i]; + } + newAnimals[newAnimals.length - 1] = animal; + animals = newAnimals; + } + } + + @Override + public void removeAnimal(Animal animal) { + Animal[] newAnimals = new Animal[animals.length - 1]; + int index = 0; + for (Animal a : animals) { + if (a.getId() != animal.getId()) { + newAnimals[index] = a; + index++; + } + } + animals = newAnimals; + } + + @Override + public Animal searchForAnimal(String name) { + for (Animal a : animals) + if (a.getName().equals(name)) + return a; + return null; + } + + @Override + public boolean sponsorAnimal(int animalId) { + System.out.println("Sponsoring animal with id " + animalId + "..."); + System.out.print("Sponsor's name: "); + String sponsorId = new Scanner(System.in).nextLine(); + for (Animal a : animals) + if (a.getId() == animalId) { + a.setSponsor(sponsorId); + return true; + } + return false; + } + + @Override + public void listAllAnimals() { + for (Animal a : animals) + System.out.println(a.toString()+"\n"); + } +} diff --git a/1ano/2semestre/poo/src/aval/aa1/Rabbit.java b/1ano/2semestre/poo/src/aval/aa1/Rabbit.java new file mode 100644 index 0000000..cdb7124 --- /dev/null +++ b/1ano/2semestre/poo/src/aval/aa1/Rabbit.java @@ -0,0 +1,44 @@ +package aval.aa1; + +import java.util.Objects; + +public class Rabbit extends Animal { + private String fur; + + public Rabbit(String name, int weight, int age, String fur, String sponsor) { + super(name, weight, age, sponsor); + this.fur = fur; + } + + public Rabbit(String name, int weight, int age, String fur) { + super(name, weight, age); + this.fur = fur; + } + + public String getFur() { + return this.fur; + } + + public void setfur(String fur) { + this.fur = fur; + } + + @Override + public String toString() { + return "Rabbit of fur " + fur + "\n" + super.toString(); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + if (!super.equals(o)) return false; + Rabbit rabbit = (Rabbit) o; + return Objects.equals(fur, rabbit.fur); + } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode(), fur); + } +} diff --git a/1ano/2semestre/poo/src/utils/Enums/Weekday.java b/1ano/2semestre/poo/src/utils/Enums/Weekday.java new file mode 100644 index 0000000..efa928f --- /dev/null +++ b/1ano/2semestre/poo/src/utils/Enums/Weekday.java @@ -0,0 +1,31 @@ +package utils.Enums; + +public enum Weekday { + MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY; + + public static Weekday fromString(String string) { + return switch (string) { + case "MONDAY", "Monday", "monday" -> MONDAY; + case "TUESDAY", "Tuesday", "tuesday" -> TUESDAY; + case "WEDNESDAY", "Wednesday", "wednesday" -> WEDNESDAY; + case "THURSDAY", "Thursday", "thursday" -> THURSDAY; + case "FRIDAY", "Friday", "friday" -> FRIDAY; + case "SATURDAY", "Saturday", "saturday" -> SATURDAY; + case "SUNDAY", "Sunday", "sunday" -> SUNDAY; + default -> null; + }; + } + + @Override + public String toString() { + return switch (this) { + case MONDAY -> "MONDAY"; + case TUESDAY -> "TUESDAY"; + case WEDNESDAY -> "WEDNESDAY"; + case THURSDAY -> "THURSDAY"; + case FRIDAY -> "FRIDAY"; + case SATURDAY -> "SATURDAY"; + case SUNDAY -> "SUNDAY"; + }; + } +}