Simple Calculator

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
User avatar
BarnD
Prole
Posts: 49
Joined: Wed Jun 16, 2010 1:23 pm
Location: Australia
Contact:

Simple Calculator

Post by BarnD »

Who says love needs to be used to only make games..
I got bored so I created a simple calculator, doing this also helped with me learning a few things with lua since I'm still newish to it.

Edit, made the buttons cooler, but still not OO.
Still also has the errors if you do things like 1**1, dunno what to do about that
SimpleCalculator.love
Simple Calculator
(1.4 KiB) Downloaded 204 times
p.s. Someone should look at my code and tell me if I'm going in the right direction. :)
Last edited by BarnD on Tue Apr 26, 2011 1:51 pm, edited 3 times in total.
User avatar
TechnoCat
Inner party member
Posts: 1611
Joined: Thu Jul 30, 2009 12:31 am
Location: Denver, CO
Contact:

Re: Simple Calculator

Post by TechnoCat »

1 * * 1
User avatar
BarnD
Prole
Posts: 49
Joined: Wed Jun 16, 2010 1:23 pm
Location: Australia
Contact:

Re: Simple Calculator

Post by BarnD »

TechnoCat wrote:1 * * 1
+
BarnD wrote:Simple Calculator

=
calculator too dumb to do that
User avatar
TechnoCat
Inner party member
Posts: 1611
Joined: Thu Jul 30, 2009 12:31 am
Location: Denver, CO
Contact:

Re: Simple Calculator

Post by TechnoCat »

Your code is pretty good, but your buttons could use an OO makeover.
Instead of hard-coding a switch statement into your button function, you could have a button object that accepts a function instead.
User avatar
BarnD
Prole
Posts: 49
Joined: Wed Jun 16, 2010 1:23 pm
Location: Australia
Contact:

Re: Simple Calculator

Post by BarnD »

TechnoCat wrote:your buttons could use an OO makeover
Yeah, I need to read up on my OOP.
And thanks for your feedback.
Post Reply

Who is online

Users browsing this forum: Semrush [Bot] and 32 guests