From c632b75f802feaa525aa9baf4725c6beb3f305aa Mon Sep 17 00:00:00 2001 From: TiagoRG <35657250+TiagoRG@users.noreply.github.com> Date: Wed, 12 Apr 2023 22:52:52 +0100 Subject: [PATCH 1/2] [POO] tp_codecheck tp3 part2.1 --- .../tp03/{ => part1}/TrafficLight1.java | 2 +- .../tp03/{ => part1}/TrafficLight2.java | 2 +- .../tp_codecheck/tp03/part2/RentalCar.java | 72 +++++++++++++++++++ 3 files changed, 74 insertions(+), 2 deletions(-) rename 1ano/2semestre/poo/src/tp_codecheck/tp03/{ => part1}/TrafficLight1.java (97%) rename 1ano/2semestre/poo/src/tp_codecheck/tp03/{ => part1}/TrafficLight2.java (97%) create mode 100644 1ano/2semestre/poo/src/tp_codecheck/tp03/part2/RentalCar.java diff --git a/1ano/2semestre/poo/src/tp_codecheck/tp03/TrafficLight1.java b/1ano/2semestre/poo/src/tp_codecheck/tp03/part1/TrafficLight1.java similarity index 97% rename from 1ano/2semestre/poo/src/tp_codecheck/tp03/TrafficLight1.java rename to 1ano/2semestre/poo/src/tp_codecheck/tp03/part1/TrafficLight1.java index 16a2a86..b8c314f 100644 --- a/1ano/2semestre/poo/src/tp_codecheck/tp03/TrafficLight1.java +++ b/1ano/2semestre/poo/src/tp_codecheck/tp03/part1/TrafficLight1.java @@ -1,4 +1,4 @@ -package tp_codecheck.tp03; +package tp_codecheck.tp03.part1; /** A simulated traffic light. diff --git a/1ano/2semestre/poo/src/tp_codecheck/tp03/TrafficLight2.java b/1ano/2semestre/poo/src/tp_codecheck/tp03/part1/TrafficLight2.java similarity index 97% rename from 1ano/2semestre/poo/src/tp_codecheck/tp03/TrafficLight2.java rename to 1ano/2semestre/poo/src/tp_codecheck/tp03/part1/TrafficLight2.java index 154113d..a929261 100644 --- a/1ano/2semestre/poo/src/tp_codecheck/tp03/TrafficLight2.java +++ b/1ano/2semestre/poo/src/tp_codecheck/tp03/part1/TrafficLight2.java @@ -1,4 +1,4 @@ -package tp_codecheck.tp03; +package tp_codecheck.tp03.part1; /** A simulated traffic light. diff --git a/1ano/2semestre/poo/src/tp_codecheck/tp03/part2/RentalCar.java b/1ano/2semestre/poo/src/tp_codecheck/tp03/part2/RentalCar.java new file mode 100644 index 0000000..f10c708 --- /dev/null +++ b/1ano/2semestre/poo/src/tp_codecheck/tp03/part2/RentalCar.java @@ -0,0 +1,72 @@ +package tp_codecheck.tp03.part2; + +public class RentalCar { + private boolean rented; + private static int rentedCount = 0; + private static int availableCount = 0; + + /** + * Constructs a rental car. + */ + public RentalCar() { + // your work here + rented = false; + RentalCar.availableCount++; + } + + /** + * Get number of cars available. + * + * @return count of cars that are available + */ + public static int numAvailable() { + // your work here + return RentalCar.availableCount; + } + + /** + * Get number of cars rented. + * + * @return count of cars that are rented + */ + public static int numRented() { + // your work here + return RentalCar.rentedCount; + } + + /** + * Try to rent this car. + * + * @return true if the car was successfully rented, false if it was already + * rented + */ + public boolean rentCar() { + // your work here + if (this.rented) { + return false; + } else { + this.rented = true; + RentalCar.rentedCount++; + RentalCar.availableCount--; + return true; + } + } + + /** + * Return rented car. + * + * @return true if the car was previously rented and is now returned, + * false if it was not previously rented + */ + public boolean returnCar() { + // your work here + if (this.rented) { + this.rented = false; + RentalCar.rentedCount--; + RentalCar.availableCount++; + return true; + } else { + return false; + } + } +} From 1388852f3c57bb582a859d3d75dfc6192fc9cd1b Mon Sep 17 00:00:00 2001 From: TiagoRG <35657250+TiagoRG@users.noreply.github.com> Date: Wed, 12 Apr 2023 22:53:21 +0100 Subject: [PATCH 2/2] Main README update --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bb7f8ca..29b3a1f 100755 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# UAveiro - LECI +# UAveiro - LECI | [Wiki](https://github.com/TiagoRG/uaveiro-leci/wiki) ### Todo o material de Licenciatura em Engenharia de Computatores e Informática ### [Free for Use] ---