-
Notifications
You must be signed in to change notification settings - Fork 14
My second assignment #3
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: master
Are you sure you want to change the base?
Conversation
abeprosper
left a comment
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.
Great effort. I hope for future assignments you will be able to attempt all questions. Here is a link to your grade:
https://docs.google.com/document/d/1wAnW7AIuZm4eOW7u7SpwLjalPV0UMJMeG__VA2kBzTM/edit?usp=sharing
| } | ||
|
|
||
| /* | ||
| * File: FindRange.java |
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.
Your program doesn't work correctly because you have an incorrect value of the SENTINEL. You set it to 20 instead of 0. Also it misses the following two edge cases:
If the user enters only one value before the sentinel, the program should report
that value as both the largest and smallest
and
If the user enters the sentinel on the very first input line, then no values have been
entered, and your program should display a message to that effect.
| println("The minimum value is " +min); | ||
| println("The maximum value is " +max); | ||
| } | ||
| private static final int SENTINEL = 20; |
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 should be 0.
| * Name: | ||
| * Section Leader: | ||
| * -------------------- | ||
| * This file is the starter file for the Hailstone problem. |
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.
Great solution.
|
|
||
| import acm.graphics.*; | ||
| import acm.program.*; | ||
| import java.awt.*; |
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.
I suppose you didn't have enough time to code this part. :(
| } | ||
| } | ||
|
|
||
|
|
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.
Excellent solution.
| /* You fill this in */ | ||
| } | ||
| } | ||
| /* |
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.
Excellent solution.
| /* You fill this in. */ | ||
| } | ||
| } | ||
| /* |
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.
Great solution. Just a few technical issues.
| public void run() { | ||
| /* | ||
| * This program draws an archery target | ||
| */ |
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.
These values should have been declared as constants outside of the run method. So something like:
private static final int INCH_TO_PIX = 72;
private static final double MAXI_RADIUS = 1 * INCH_TO_PIX;
private static final double MEDI_RADIUS = 0.65 * INCH_TO_PIX;
private static final double MINI_RADIUS = 0.3 * INCH_TO_PIX;
| miniTarget.setFilled(true); | ||
| miniTarget.setColor(Color.RED); | ||
| add(miniTarget); | ||
| } |
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.
The operation to draw the circles should have been done in a method since they all share code. So something like this:
private void drawCircle(double centerX, double centerY, double rad, Color c) {
GOval circle = new GOval(centerX - rad, centerY - rad, 2*rad, 2*rad);
circle.setColor(c);
circle.setFillColor(c);
circle.setFilled (true);
add (circle);
}
No description provided.