Skip to content

Conversation

@Igoche
Copy link

@Igoche Igoche commented Jun 6, 2017

my second assignment

Copy link

@abeprosper abeprosper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work. Better work than in first assignment.

See your grade here:
https://docs.google.com/document/d/15XSpxowxIt6Q0MYndrf1Loixk2eUJrOMAsuwzawTspk/edit?usp=sharing

}
}

/*

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Program doesn't work accurately. It fails the following two cases described in the assignment:

If the user enters only one value before the sentinel, the program should report
that value as both the largest and smallest

So for example if someone enters 5 followed by 0 the program should report:
smallest: 5
largest: 5
Your program instead reports
smallest: 0
largest: 5

Also

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.

So if for example the user enters 0 the program should report:
No values has been entered.
Your program instead reports:
Smallest: 0
Largest: 0

}

/*
* File: Hailstone.java

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent solution!!!

import acm.program.*;
import java.awt.*;

public class ProgramHierarchy extends GraphicsProgram {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should breakdown your program into smaller understandable methods. So the run method should have looked like this

public void run() {
    drawProgramBox();
    drawConsoleLine();
    drawConsoleBox();
    drawGraphicsLine();
    drawGraphicsBox();
    drawDialogLine();
    drawDialogBox();
}

And then you would have gone ahead and implement each method.

GRect Rect4 = new GRect((x+175), (y+100), WIDTH, HEIGHT);
add(Rect4);

GLabel label4 = new GLabel("DialogProgram", (x + 210), (y + 130));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally you should avoid the use of constant numbers in your program. You have values like (210, 130, 175, 145...etc) throughout your code and this is not a good idea because:

  1. Someone reading your code will be confused how you came up with them
  2. If requirements change your program will be really hard to update. For example imagine for this exercise the requirements changed and we decide that the value for HEIGHT (50) and WIDTH (150) should be changed to HEIGHT = 60 and
    WIDTH = 180

If this happens your program will fail to draw the right diagram. To make it work you will have to go back and start changing all the numbers throughout your program. It should be possible to come up with a solution that works without you doing further modification. The ability of a program to be able to adapt to changes like that is called scalability. So in this case your solution is not scalable enough.

}
}

/*

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work on this one. Now this is a scalable solution (unlike your solution in ProgramHierarchy.java). Now if we decide to change BRICKS_IN_BASE to 20 (instead of 14) and BRICK_WIDTH to 35 (instead of 30) . Your program still draws the right pyramid without you having to go and change things within the code.

* -----------------------------
* This file is the starter file for the PythagoreanTheorem problem.
*/

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent work.

}
}
/*
* File: Target.java

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The radius and pixel values should have been constants similar to what the starter code for the pyramid question had brick width, brick height and number of bricks on the base as constants. So you should have had something like this:

private static final int PIXELS_PER_INCH = 72;
private static final double RADIUS_OUTER_CIRCLE = 1.0;
private static final double RADIUS_WHITE_CIRCLE = 0.65;
private static final double RADIUS_INNER_CIRCLE = 0.3;

Also again this solution is not scalable (If the assignment requirements changed to have different radiuses your program will not work) and I don't think it uses the right measurements provided by the question (specifically the radiuses: 1.0, 0.65 and 0.3)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants