Solution/002 lotto fake extraction#2
Conversation
| str: Wheel selected by the user. | ||
| """ | ||
| print("\nChoose a 'ruota' from the list below:\n") | ||
| ruote: List[str] = [ |
There was a problem hiding this comment.
this list should never change, I know, but I would have expected a scalable approach that reads data from a file, thereby avoiding the need to modify the code in the future if the list were to change for any reason
| ] | ||
|
|
||
| while True: | ||
| for i, route in enumerate(ruote, start=1): |
There was a problem hiding this comment.
I would have expected a class dedicated to the routes list and various methods to do "things" on that list, as the print of the entire list, and others. Remember always the DRY (Don't Repeat Yourself) principle
| """ | ||
| print("\nChoose a 'giocata' from the list below:\n") | ||
| giocate_list: dict[str, int] = { | ||
| "Ambata": 1, |
| } | ||
| keys: List[str] = list(giocate_list.keys()) | ||
|
|
||
| for i, play in enumerate(keys, start=1): |
There was a problem hiding this comment.
same as my comment on the DRY principle
| """Initializes the controller and the ticket generator.""" | ||
| self.bill_generator: BillGenerator = BillGenerator() | ||
| self.extraction = Extraction() | ||
| self.winning_bill: WinningBill |
There was a problem hiding this comment.
you must always initialize the properties inside the constructor. In this case, self.winning_bill doesn't exist until you set it this way self.winning_bill=WinningBill(bla, bla, bla, ecc).
I don't find any snippet like this, you are using the WinningBill but it isn't a property in the Controller
| numbers: List[int] = self.bill_generator.get_numbers(numbers_in_bills) | ||
| bill: Bill = Bill(giocata_name, ruota, numbers) | ||
| self.bills[number] = bill | ||
| print(type(self.bills)) |
| Returns: | ||
| List[str]: A list containing the names of all Lotto wheels. | ||
| """ | ||
| ruote: List[str] = [ |
There was a problem hiding this comment.
how many times did you repeat the same code?
| is a winning one based on the extracted numbers. | ||
|
|
||
| """ | ||
| GIOCATE_RULES = { |
There was a problem hiding this comment.
if you want handle the rules this way (even if I don't agree), define it as a CONSTANT common to the entire project and recall from any file/class you need.
If you set the variable in the class but out of the constructor, the var will be shared to every instance of the class, which isn't a best practice
No description provided.