Skip to content
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

Solved tasks from ReadMe file #1292

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

DEz-1996
Copy link

No description provided.

Copy link

@bhdnchui bhdnchui left a comment

Choose a reason for hiding this comment

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

Good job, but a few comments need to be fixed.

@@ -0,0 +1,10 @@
package core.basesyntax.enums;

public enum FigureColor {
Copy link

Choose a reason for hiding this comment

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

Let's simplify. Just Color.

package core.basesyntax.figures;

public interface Drawable {
void toDraw();
Copy link

Choose a reason for hiding this comment

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

Just draw, maybe would be better?

protected int area;

@Override
public void toDraw() {
Copy link

Choose a reason for hiding this comment

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

You can make thin class abstract and not override a method with empty implementation.

for (int i = 0; i < ARRAY_LENGTH; i++) {
if (i < ARRAY_LENGTH / 2) {
figures[i] = figureSupplier.getRandomFigure();
continue;
Copy link

Choose a reason for hiding this comment

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

Do not use continue, use just if {} else {}.


public class ColorSupplier {
private final Random random = new Random();
private final int randomIndex = random.nextInt(FigureColor.values().length);
Copy link

Choose a reason for hiding this comment

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

This random index will be created once on creating ColorSupplier.
I think you should have a random index on every getRandomColor method call.

Comment on lines 25 to 37
if (randomIndex == 0) {
return new Circle(randomColor, randomProperty1);
}
if (randomIndex == 1) {
return new IsoscelesTrapezoid(randomColor,
randomProperty1, randomProperty2, randomProperty3);
}
if (randomIndex == 2) {
return new Rectangle(randomColor, randomProperty1, randomProperty2, randomProperty3);
}
if (randomIndex == 3) {
return new RightTriangle(randomColor, randomProperty1, randomProperty2);
}
Copy link

Choose a reason for hiding this comment

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

Looks like a custom switch. Lets use default java switch.

Comment on lines 21 to 23
int randomProperty1 = random.nextInt(MAX_VALUE_OF_PROPERTY);
int randomProperty2 = random.nextInt(MAX_VALUE_OF_PROPERTY);
int randomProperty3 = random.nextInt(MAX_VALUE_OF_PROPERTY);
Copy link

Choose a reason for hiding this comment

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

I think it is redundant. You can create object with the text logic:

 return new Circle(colorSupplier.getRandomColor(), getRandomValue());

int randomProperty1 = random.nextInt(MAX_VALUE_OF_PROPERTY);
int randomProperty2 = random.nextInt(MAX_VALUE_OF_PROPERTY);
int randomProperty3 = random.nextInt(MAX_VALUE_OF_PROPERTY);
String randomColor = new ColorSupplier().getRandomColor();
Copy link

Choose a reason for hiding this comment

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

Think about this.

this.sideEdge = sideEdge;
this.topSide = topSide;
this.downSide = downSide;
this.area = ((topSide * downSide) / 2) * sideEdge;
Copy link

Choose a reason for hiding this comment

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

Does that formula calculate area of the isosceles trapezoid?

this.firstSide = firstSide;
this.secondSide = secondSide;
this.thirdSide = thirdSide;
this.area = firstSide * secondSide * thirdSide;
Copy link

Choose a reason for hiding this comment

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

How does Rectangle translate?
How do we calculate it's area?

@DEz-1996 DEz-1996 requested a review from bhdnchui October 3, 2023 13:50
Copy link

@d1sam d1sam left a comment

Choose a reason for hiding this comment

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

Well done!

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.

3 participants