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

done 1.0 #1769

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

done 1.0 #1769

wants to merge 2 commits into from

Conversation

OleksiiVitiuk
Copy link

No description provided.

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

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


Thank you for your hard work on this project! While your code largely meets the task requirements, there are a few critical issues that need to be addressed before we can approve the pull request:

  1. Redundant Fields: The color field is redundantly declared in multiple classes (Circle, Square, RightTriangle, Rectangle, IsoscelesTrapezoid) even though it is already defined in the AbstractFigure class. This redundancy can lead to confusion and potential errors, so it should be removed from these classes.

  2. Misspelled Variable: The variable heigth is misspelled in several places. It should be corrected to height to maintain code clarity and prevent potential bugs.

  3. Unreachable Code: In the FigureSupplier class, the random.nextInt(4) call only generates numbers from 0 to 3, making the case 4 for Rectangle unreachable. Adjust this to random.nextInt(5) to ensure all cases are covered.

These issues impact the functionality and clarity of your code. Once these are resolved, your code will be in great shape! Keep up the great work, and I look forward to seeing the improvements. 😊

✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨

🔄 Fix the issues, commit the changes, and then re-request my review using the Re-request review button in the Reviewers tab.

package core.basesyntax;

public class Circle extends AbstractFigure {
private String color;

Choose a reason for hiding this comment

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

The color field is redundant here because it is already defined in the AbstractFigure class. You should remove this field from the Circle class to avoid confusion and potential errors.

Random random = new Random();
ColorSupplier colorSupplier = new ColorSupplier();
String color = colorSupplier.getRandomColor();
int figureType = random.nextInt(4);

Choose a reason for hiding this comment

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

The random.nextInt(4) call will only generate numbers from 0 to 3. Therefore, the case 4 for Rectangle is unreachable. You should change random.nextInt(4) to random.nextInt(5) to include all cases.

return new Circle(color,radius);
case 1: //RightTriangle
double base = 1 + random.nextInt(10);
double heigth = 1 + random.nextInt(10);

Choose a reason for hiding this comment

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

The variable heigth is misspelled. It should be height.

case 3: //IsoscelesTrapezoid
double side1 = 1 + random.nextInt(10);
double side2 = 1 + random.nextInt(10);
heigth = 1 + random.nextInt(10);

Choose a reason for hiding this comment

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

The variable heigth is misspelled. It should be height.

Comment on lines +13 to +30
double radius = 1 + random.nextInt(10);
return new Circle(color,radius);
case 1: //RightTriangle
double base = 1 + random.nextInt(10);
double heigth = 1 + random.nextInt(10);
return new RightTriangle(color,base,heigth);
case 2: //Square
double side = 1 + random.nextInt(10);
return new Square(color,side);
case 3: //IsoscelesTrapezoid
double side1 = 1 + random.nextInt(10);
double side2 = 1 + random.nextInt(10);
heigth = 1 + random.nextInt(10);
return new IsoscelesTrapezoid(color,side1,side2,heigth);
case 4: //Rectangle
double length = 1 + random.nextInt(10);
double width = 1 + random.nextInt(10);
return new Rectangle(color,length,width);

Choose a reason for hiding this comment

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

Consider using constants for the magic numbers (e.g., 1 and 10) to improve code readability and maintainability.

public class RightTriangle extends AbstractFigure {
private String color;
private double base;
private double heigth;

Choose a reason for hiding this comment

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

The variable heigth is misspelled. It should be height.

Comment on lines +8 to +11
public RightTriangle(String color,double base, double heigth) {
super(color);
this.base = base;
this.heigth = heigth;

Choose a reason for hiding this comment

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

The variable heigth is misspelled. It should be height.

}

public double getArea() {
return 0.5 * base * heigth;

Choose a reason for hiding this comment

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

The variable heigth is misspelled. It should be height.


@Override
public String describe() {
return "RightTriange " + getColor() + " base: " + base + " heigth: "

Choose a reason for hiding this comment

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

The variable heigth is misspelled. It should be height.

package core.basesyntax;

public class Square extends AbstractFigure {
private String color;

Choose a reason for hiding this comment

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

The color field is redundant here because it is already defined in the AbstractFigure class. You should remove this field from the Square class to avoid confusion and potential errors.

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

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

Great job on addressing most of the previous review comments! 🎉 Your implementation of the AbstractFigure class and its subclasses is well-structured, and you've successfully removed redundant fields, which is excellent. However, there are a couple of minor issues that need attention:

  1. Misspelled Variable: The variable heigth is still misspelled in the RightTriangle and IsoscelesTrapezoid classes. Please correct it to height to maintain consistency and prevent potential bugs.

  2. Code Functionality: The FigureSupplier class now correctly uses random.nextInt(5) to ensure all cases are reachable, which is a good improvement.

Your code largely meets the task requirements, and the decision to approve is made to help you move forward with your learning. Please review the comments and make the necessary corrections to improve your code. Keep up the good work, and continue learning from these experiences! 🚀

✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨

return new Circle(color,radius);
case 1: //RightTriangle
double base = 1 + random.nextInt(10);
double heigth = 1 + random.nextInt(10);

Choose a reason for hiding this comment

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

The variable heigth is misspelled. It should be height to maintain code clarity and prevent potential bugs.

case 3: //IsoscelesTrapezoid
double side1 = 1 + random.nextInt(10);
double side2 = 1 + random.nextInt(10);
heigth = 1 + random.nextInt(10);

Choose a reason for hiding this comment

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

The variable heigth is misspelled. It should be height to maintain code clarity and prevent potential bugs.

public class IsoscelesTrapezoid extends AbstractFigure {
private double base1;
private double base2;
private double heigth;

Choose a reason for hiding this comment

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

The variable heigth is misspelled. It should be height to maintain code clarity and prevent potential bugs.

super(color);
this.base1 = base1;
this.base2 = base2;
this.heigth = height;

Choose a reason for hiding this comment

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

The variable heigth is misspelled. It should be height to maintain code clarity and prevent potential bugs.

}

public double getArea() {
return 0.5 * (base1 + base2) * heigth;

Choose a reason for hiding this comment

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

The variable heigth is misspelled. It should be height to maintain code clarity and prevent potential bugs.

private double base;
private double heigth;

public RightTriangle(String color,double base, double heigth) {

Choose a reason for hiding this comment

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

The variable heigth is misspelled. It should be height to maintain code clarity and prevent potential bugs.

public RightTriangle(String color,double base, double heigth) {
super(color);
this.base = base;
this.heigth = heigth;

Choose a reason for hiding this comment

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

The variable heigth is misspelled. It should be height to maintain code clarity and prevent potential bugs.

}

public double getArea() {
return 0.5 * base * heigth;

Choose a reason for hiding this comment

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

The variable heigth is misspelled. It should be height to maintain code clarity and prevent potential bugs.


@Override
public String describe() {
return "RightTriange " + getColor() + " base: " + base + " heigth: "

Choose a reason for hiding this comment

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

The variable heigth is misspelled. It should be height to maintain code clarity and prevent potential bugs.

@Override
public String describe() {
return "RightTriange " + getColor() + " base: " + base + " heigth: "
+ heigth + " area: " + getArea();

Choose a reason for hiding this comment

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

The variable heigth is misspelled. It should be height to maintain code clarity and prevent potential bugs.

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