Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.025 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'else:': 0.03; 'variables': 0.07; 'caller': 0.09; 'classes.': 0.09; 'constructor': 0.09; 'logic': 0.09; 'worse': 0.09; 'python': 0.11; 'def': 0.12; '18:': 0.16; 'name):': 0.16; 'readable': 0.16; 'side.': 0.16; 'somewhere.': 0.16; 'subject:hotel': 0.16; 'variable.': 0.16; 'write.': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'variable': 0.18; 'split': 0.19; 'code,': 0.22; 'print': 0.22; 'header:User- Agent:1': 0.23; 'pass': 0.26; 'defined': 0.27; 'values': 0.27; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'errors': 0.30; "i'm": 0.30; 'code': 0.31; 'easier': 0.31; 'posting': 0.31; 'another.': 0.31; 'class': 0.32; 'quite': 0.32; 'maybe': 0.34; 'advice': 0.35; 'but': 0.35; 'there': 0.35; 'really': 0.36; 'adjust': 0.36; 'functions.': 0.36; 'returning': 0.36; 'method': 0.36; 'should': 0.36; 'project': 0.37; 'starting': 0.37; 'step': 0.37; 'handle': 0.38; 'to:addr:python-list': 0.38; 'anything': 0.39; 'does': 0.39; 'sure': 0.39; 'to:addr:python.org': 0.39; 'system.': 0.39; 'ensure': 0.60; 'even': 0.60; 'hotel': 0.61; 'first': 0.61; 'name': 0.63; 'more': 0.64; 'total': 0.65; 'management': 0.65; 'here': 0.66; 'received:at': 0.68; 'wish': 0.70; 'obvious': 0.74; 'age': 0.80; 'counts': 0.83; 'bar:': 0.84; 'beside': 0.84; 'florian': 0.84; 'subject:system': 0.84; 'drink': 0.93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=logic.at; s=mail; t=1414591945; bh=Rey5C67YTLpAqAvcl0axBDTn46agpZRPIrIsOXGdiTI=; h=Date:From:To:Subject:References:In-Reply-To:From; b=U5/f60+7rHoDBT+naR6NpqwqXv6Xk/Ng6ih3vowkaEz71oo0XuFcCuHZwy8vHgPJ0 Vzic2Fyr1VVHAUylt6eT+S1fqgUG809VjOkqk8ONBzrGyKDXM4yDeOA/vFOsTGJMv6 oqeQXWBdeAxKEIZ4ErVoZ6HM1kfks8x9qo9r0Q4U= Date: Wed, 29 Oct 2014 15:12:14 +0100 From: Florian Schweikert User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: python-list@python.org Subject: Re: hotel management system References: <3f10c652-9d9d-4353-b24f-939d21978998@googlegroups.com> In-Reply-To: <3f10c652-9d9d-4353-b24f-939d21978998@googlegroups.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 73 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1414592507 news.xs4all.nl 2932 [2001:888:2000:d::a6]:52859 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:79914 On 28/10/14 07:42, ngangsia akumbo wrote: > Please can someone look at my code and may be advice and may be help me with some correction. I have been learning python for some time now. This is my first project i wish to write. A hotel management system. > > > http://pastebin.com/LMHmuTiC Beside posting the code inline, it would be easier if you had split the "employee" part and the part with the classes. I'm not sure what you want to accomplish with this code, but I picked a few parts: > if age >= 18: > pass > > else: > return age_lim() using a function just to print a single line is quite overcomplicated. return the result and handle it on the caller side. why do you use if/else and just pass first path? if age<18: do_something do the same thing. I have to guess what the class part should do. > class Bar: why calling a class Bar if you use it like some drink counter? > total_cost = 0 > count = 0 not sure you want to use class variables here, do you want to count amount of a single type of beer? or everything > def set_name(self, name): > self.name = name > return name don't use setter if there is 0 logic in the function also it would be better to set this things in the constructor otherwise and a setter should not return the name just set > def set_count(self): > counts = Bar.count =+ 1 not really readable code style, counts variable is unneccessary here > # still have to adjust this section > > def set_total_cost(self): #I am having some errors #calling this functions > total = set_price() * set_count() > print "Total cost of drinks: ", total > pass well, it's quite obvious this function crashes, you try to use not defined functions. you have to use self.function_name to access the methods. But worse than this you want to use (useless) setter to get values and print them inside the method instead of returning the value and handle it outside. Also this is not even a setter, it does not set anything beside a local variable. Maybe it would be best you start over again and make one step after another. Build one part of code and ensure it works before starting with more code. And ask specific questions if you stuck somewhere. -- Florian