-
Notifications
You must be signed in to change notification settings - Fork 28
Wordy Completed - Lucy Rubin #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Good work! For the final step of this assignment:
Walk through the two solutions, comparing one small chunk of code at a time. Things to think about as you go:
Now, to complete the assignment: Write a brief note about one or two things that stood out to you as you compare the two solutions. You can ask a question, or just name something notable. Post these comments here in this comment thread and/or as comments on individual lines of your code in the “Files changed” tab. |
@@ -59,4 +62,57 @@ public String toString() { | |||
protected String describeAttributes() { | |||
return "(operator=" + operator + ')'; | |||
} | |||
|
|||
@Override | |||
protected double doEvaluate(EvaluationContext context) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I wrote for this method works, but Paul's version is safer. If an invalid operator were to be passed, the method would return 0.0, which could be very bad.
} | ||
|
||
@Override | ||
public void compile(PrintWriter out) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method has the same issue as the previous one. My code and Paul's code do essentially the same thing, but mine doesn't protect against invalid operators
|
||
@Override | ||
public void compile(PrintWriter out) { | ||
out.print("{"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My code is the same as Paul's, except I didn't use println(). It would have made it more human-readable if I did that, but it isn't necessary for it to work.
@@ -72,4 +75,56 @@ public String toString() { | |||
protected String describeAttributes() { | |||
return "(operator=" + operator + ')'; | |||
} | |||
|
|||
@Override | |||
protected void doRun(EvaluationContext context) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My code and Paul's code both are fine. They are just different approaches.
No description provided.