Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

minor fixes

  • Loading branch information...
commit 081b3525778428b5ecb6d4c6a63d753cae0e54ff 1 parent fe29e32
@WonderCsabo authored
Showing with 8 additions and 7 deletions.
  1. +4 −1 core.cpp
  2. +2 −3 enterbutton.cpp
  3. +2 −3 main.cpp
View
5 core.cpp
@@ -259,7 +259,7 @@ string Core::GetResult() //evaluating the result
rpn.pop_front(); // the token is read, read the next
}
- if(((valStack.size() > 1 || valStack.empty()) && bad) || bad) // if not one value remained
@WonderCsabo Owner

Only this type of error was returned, fixed it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ if(valStack.size() > 1 || valStack.empty()) // if not one value remained
return "hibas kifejezes"; //error
else if(bad && valStack.top() == 1)
return "osztas nullaval"; //division by zero
@@ -267,6 +267,9 @@ string Core::GetResult() //evaluating the result
return "MOD es nem egesz szam"; //modulus with non-integer
else if(bad && valStack.top() == 3)
return "paros gyok, alap < 0"; //complex result of sqrt
+ else if(bad) // if not one value remained
+ return "hibas kifejezes"; //error
+
else // if it's okay, return the result
{
View
5 enterbutton.cpp
@@ -7,8 +7,7 @@ void EnterButton::Action(std::string &s)
{
if(!s.empty() && s[s.length()-1] != '!') //if we didnt got a result already
{
- Core *c = new Core(s); //converting to postfix RPN
- s = c->GetResult()+"!"; //calculating the result
- delete c;
+ Core c(s); //converting to postfix RPN
+ s = c.GetResult()+"!"; //calculating the result
}
}
View
5 main.cpp
@@ -3,8 +3,7 @@
int main()
{
- Application *app = new Application(212,239);
- app->Run();
- delete app;
+ Application app(212,239);
+ app.Run();
return 0;
}

1 comment on commit 081b352

@WonderCsabo

Only this type of error was returned, fixed it.

@WonderCsabo

Does not need dinamic allocating in main() and Enterbutton::Action()

Please sign in to comment.
Something went wrong with that request. Please try again.