diff --git a/subjects/borrow_box/README.md b/subjects/borrow_box/README.md index 7518656a..3571adfd 100644 --- a/subjects/borrow_box/README.md +++ b/subjects/borrow_box/README.md @@ -4,18 +4,18 @@ In this exercise, a **CRUD** functionality will have to be created. Therefore the following functions will have to be defined : -- `new`, which receives two players and initializes them with a name and a score. This functions should +- `new`, which receives two players and initializes them with a name and a score. This function should return the structure wrapped in a Box. - `read_winner`, which returns a tuple with the name and the score of the player who is winning. In case none of the players are winning, it should return the same tuple with the string "Same score! tied" and the tied score. - - `update_score`, which receives the name of a player. - This function should increment the score of the player. The score should only be increased if it does not pass the `nbr_of_games`. - Example: if the nbr_of_games is 3 then the winner of the game should be the one who is the best out of three games. So if one play as 2 wins then - he is the winner and the function should not increase the score anymore for either players. +- `update_score`, which receives the name of a player. + This function should increment the score of the player. The score should only be increased if it does not pass the `nbr_of_games`. + Example: if the nbr_of_games is 3 then the winner of the game should be the one who is the best out of three games. So if one play has 2 wins then + he is the winner and the function should not increase the score anymore for either player. -- `delete`, which takes the ownership of the boxed game and returning a string : "Game deleted: id -> 0". +- `delete`, which takes the ownership of the boxed game and returns a string: "game deleted: id -> 0". ### Notions @@ -26,8 +26,12 @@ In this exercise, a **CRUD** functionality will have to be created. Therefore th ```rust #[derive(Debug, Clone, Eq, PartialEq)] pub struct Game { - // expected public fields + pub id: u32, + pub p1: (String, u16), + pub p2: (String, u16), + pub nbr_of_games: u16 } + impl Game { pub fn new(i: u32, pl1: String, pl2: String, n: u16) -> Box { diff --git a/subjects/box_recursion/README.md b/subjects/box_recursion/README.md index 47288a5f..01209a0e 100644 --- a/subjects/box_recursion/README.md +++ b/subjects/box_recursion/README.md @@ -15,7 +15,6 @@ Do not forget that this will be a recursion type and it must point to `None` if ### Notions -- [enum](https://doc.rust-lang.org/rust-by-example/custom_types/enum.html) - [boc](https://doc.rust-lang.org/book/ch15-01-box.html) - [Module std::option](https://doc.rust-lang.org/std/option/) diff --git a/subjects/drop_the_thread/README.md b/subjects/drop_the_thread/README.md index e16804f1..55b11a47 100644 --- a/subjects/drop_the_thread/README.md +++ b/subjects/drop_the_thread/README.md @@ -17,15 +17,15 @@ in this exercise a Drop checker API has to be created. For this you must define: - `cmd`, the name of the thread. - `parent`, that will be the link to the structure `Workers` (Tip: this must be a reference to the structure Workers) -- Implementation of each structure: +- Implementation of each structure:state - `Workers` : - `new`, that creates a default worker - `new_worker`, that returns a tuple with the `pid` and a new `Thread`, this function must receive a `String` being the `cmd` - - `is_dropped`, that receives a `pid` and returns a `bool` that indicates the state of the thread by using the `pid` - - `track_worker`, it should return a `usize`, that will be the last available index of the `states` vector, being the new next thread + - `is_dropped`, that receives a `pid` and returns a `bool` that indicates the state of the thread by using the `pid` + - `track_worker`, it should return a `usize`, that will be the last available index of the `states` vector, being the new next thread - `add_drop`, this function must be **called by the `Drop` trait**. It will receive a `pid` that will be used to change the state of the thread. If the state of that thread is `true` then it will panic with the message ("Cannot drop {}, because its already dropped", pid). Otherwise it should change the state to true and increment the `drops` field by one. @@ -50,7 +50,7 @@ use std::cell::{RefCell, Cell}; #[derive(Debug, Default, Clone, Eq, PartialEq)] pub struct Workers { pub drops: Cell, - pub state: RefCell> + pub states: RefCell> } impl Workers { diff --git a/subjects/expected_variable/README.md b/subjects/expected_variable/README.md index 2043e4af..312c9495 100644 --- a/subjects/expected_variable/README.md +++ b/subjects/expected_variable/README.md @@ -50,9 +50,9 @@ And its output: ```sh $ cargo run -100% close to ir +100% close to it 88% close to it None -73% close to it +67% close to it $ ``` diff --git a/subjects/lalgebra_vector/README.md b/subjects/lalgebra_vector/README.md index cf708846..c444bfb7 100644 --- a/subjects/lalgebra_vector/README.md +++ b/subjects/lalgebra_vector/README.md @@ -29,6 +29,7 @@ impl Vector { } pub fn dot(&self, other: &Self) -> Option { + } } ``` diff --git a/subjects/shopping_mall/README.md b/subjects/shopping_mall/README.md index a24795c7..9d827a69 100644 --- a/subjects/shopping_mall/README.md +++ b/subjects/shopping_mall/README.md @@ -6,10 +6,10 @@ Using the `mall` module provided create the following **functions** to help run - `biggest_store`: receives a `mall::Mall` and returns the `Store` with the biggest `square_meters`; - `highest_paid_employees`: receives a `mall::Mall` and returns a vector containing the `Employee`(s) with the highest salaries; -- `nbr_of_employees`: receives a `mall::Mall` and returns the number of employees and securities, as a `usize`, in that mall. -- `fire_old_securities`: receives a `mall::Mall` and removes from the `mall::Mall.securities` all securities who are 50 years old or older. -- `check_for_securities`: receives a `mall::Mall` and a vector of `Security` and, if there is not at least 1 security for every 200 square meters of floor size, a security should be added to the `mall::Mall.securities` -- `cut_or_raise`: receives a `mall::Mall` and raises or cuts, the salary of every employee in the mall by 10%, if the employee works for more than 10 hours +- `nbr_of_employees`: receives a `mall::Mall` and returns the number of employees and securities, as a `usize`, in that mall; +- `fire_old_securities`: receives a `mall::Mall` and removes from the `mall::Mall.securities` all securities who are 50 years old or older; +- `check_for_securities`: receives a `mall::Mall` and a vector of `Security` and, if there is not at least 1 security for every 200 square meters of floor size, a security should be added to the `mall::Mall.securities`; +- `cut_or_raise`: receives a `mall::Mall` and raises or cuts, the salary of every employee in the mall by 10%, if the employee works for more than 10 hours (consider that the securities are not employees from the mall). ### Expected Function