Browse Source

small corrections and fix typos

update-quest-08-exercises-description-c-150
davidrobert99 2 years ago
parent
commit
941955e507
  1. 18
      subjects/borrow_box/README.md
  2. 1
      subjects/box_recursion/README.md
  3. 8
      subjects/drop_the_thread/README.md
  4. 4
      subjects/expected_variable/README.md
  5. 1
      subjects/lalgebra_vector/README.md
  6. 8
      subjects/shopping_mall/README.md

18
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<Game> {

1
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/)

8
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<usize>,
pub state: RefCell<Vec<bool>>
pub states: RefCell<Vec<bool>>
}
impl Workers {

4
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
$
```

1
subjects/lalgebra_vector/README.md

@ -29,6 +29,7 @@ impl Vector<T> {
}
pub fn dot(&self, other: &Self) -> Option<T> {
}
}
```

8
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

Loading…
Cancel
Save