Quantcast
Channel: Simulating an OOP Coffee Machine - Code Review Stack Exchange
Browsing latest articles
Browse All 7 View Live

Answer by M Juckes for Simulating an OOP Coffee Machine

You might gain more OOP points by using more objects. Start by defining an exception:class NotAvailable(Exception): passWhen something runs out, you can raise the exception and have the program return...

View Article



Answer by Laurent LAPORTE for Simulating an OOP Coffee Machine

class/instance variablesIn your code, you use class variables instead of instance variables.You have to know that class variables are shared in all instance, for example:class CoffeeMachine: water =...

View Article

Answer by md2perpe for Simulating an OOP Coffee Machine

Instead of def start(self): self.running = True self.action = input("Write action (buy, fill, take, remaining, exit):\n") print() #possible choices to perform in the coffee machine if self.action ==...

View Article

Answer by Samwise for Simulating an OOP Coffee Machine

First some basic observations:Your running variable is shared across all CoffeeMachine objects -- as soon as you create one CoffeeMachine, it starts itself, and then any subsequent CoffeeMachine you...

View Article

Answer by Peilonrayz for Simulating an OOP Coffee Machine

You should split business logic and user interface.Whilst it's common to get coffee machines that are hella advanced and can talk to humans.When programming you should build in layers.I always build...

View Article


Answer by camp0 for Simulating an OOP Coffee Machine

When you have multiple if statements, like your code does, it can be an indication that you can use a visitor pattern to your code. I will use a dict in my example.Your code:def start(self):...

View Article

Simulating an OOP Coffee Machine

Today I learnt the basics of OOP. I have tried to apply them to this coffee machine project. However I'm still a beginner, and so I feel my code can be improved. Are there any tips, trick or other...

View Article
Browsing latest articles
Browse All 7 View Live




Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>
<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596344.js" async> </script>