-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Figures are calculated! #1776
base: master
Are you sure you want to change the base?
Figures are calculated! #1776
Conversation
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.
Thank you for your hard work on this pull request! 😊 While you've made great progress, there are a few critical issues that need to be addressed to meet the core requirements of the task:
-
Missing
getArea()
Methods: Each figure class (Circle
,Square
,RightTriangle
,Rectangle
,IsoscelesTrapezoid
) needs to implement agetArea()
method to calculate and return its area. This is essential for fulfilling the task requirements. -
Abstract Method in
Figure
Class: TheFigure
class should include an abstract method for calculating the area, ensuring that all subclasses implement this method. -
getDefaultFigure()
Method: TheFigureSupplier
class should have agetDefaultFigure()
method that returns a white circle with a radius of 10, as specified in the task description. -
Random Figure Generation: The
getRandomFigure()
method inFigureSupplier
should include logic to generate aCircle
, which is currently missing.
These changes are crucial for the functionality and compliance of your code with the task requirements. Once these are addressed, your solution will be much stronger. Keep up the great work, and don't hesitate to reach out if you need any help! 🚀
✨ 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.
public void draw() { | ||
System.out.println("Figure: Circle, radius:" + radius + ", color: " + getColor()); | ||
} | ||
} |
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 Circle
class should implement a getArea()
method to calculate the area of the circle. According to the task description, all figures should have a method to obtain their area. You can calculate the area of a circle using the formula Math.PI * radius * radius
.
public String getColor() { | ||
return color; | ||
} | ||
public abstract void draw(); |
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 Figure
class should include an abstract method for calculating the area, such as public abstract double getArea();
. This will ensure that all subclasses implement this method to provide the area calculation.
Random random = new Random(); | ||
String color = new ColorSupplier().getRandomColor(); | ||
|
||
return switch (random.nextInt(6)) { |
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 switch statement should include a case for generating a Circle
. Currently, the Circle
class is missing from the random figure generation.
case 3 -> new Rectangle(color, random.nextDouble() * 10, random.nextDouble() * 10); | ||
default -> new Square(color, random.nextDouble() * 10); | ||
}; | ||
} |
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.
You need to implement a getDefaultFigure()
method that returns a white circle with a radius of 10, as required by the task description.
public void draw() { | ||
System.out.println("IsoscelesTrapezoid: color = " + getColor() + ", base1 = " + base1 + ", base2 = " + base2 + ", height = " + height); | ||
} | ||
} |
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 IsoscelesTrapezoid
class should implement a getArea()
method to calculate the area of the trapezoid. The formula for the area of an isosceles trapezoid is ((base1 + base2) / 2) * height
. Implement this method to comply with the task requirements.
if (i < figures.length / 2) { | ||
figures[i] = figureSupplier.getRandomFigure(); | ||
} else { | ||
figures[i] = new Circle("Default Color", 5); |
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.
Instead of creating a Circle
with hardcoded values, use the getDefaultFigure()
method from FigureSupplier
to obtain the default figure. This will ensure that the default figure is consistent with the task requirements.
System.out.println("Figure: Rectangle, width: " + width + ", height: " + height + ", color: " + getColor()); | ||
|
||
} | ||
} |
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 Rectangle
class should implement a getArea()
method to calculate the area of the rectangle. The formula for the area of a rectangle is width * height
. Implement this method to comply with the task requirements.
public void draw() { | ||
System.out.println("RightTriangle: color = " + getColor() + ", firstLeg = " + firstLeg + ", secondLeg = " + secondLeg); | ||
} | ||
} |
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 RightTriangle
class should implement a getArea()
method to calculate the area of the triangle. The formula for the area of a right triangle is (firstLeg * secondLeg) / 2
. Implement this method to comply with the task requirements.
System.out.println("Square: color = " + getColor() + ", sideLength = " + sideLength); | ||
} | ||
|
||
} |
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 Square
class should implement a getArea()
method to calculate the area of the square. The formula for the area of a square is sideLength * sideLength
. Implement this method to comply with the task requirements.
No description provided.