-
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
Fulfilled all the conditions of the task. Created classes of figures,… #1751
base: master
Are you sure you want to change the base?
Conversation
… interfaces and implemented methods.
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 your code is mostly well-implemented, there are a few critical issues that need to be addressed before we can approve it:
-
Method Naming: There is a typo in the method name
getRundomFigure()
in theFigureSupplier
class. It should be corrected togetRandomFigure()
to ensure consistency and avoid confusion. -
Variable Naming: The
IsoscelesTrapezoid
class has a typo in the field namehight
. This should be corrected toheight
to maintain clarity and correctness. -
Type Safety: Across several classes, consider using the
Color
enum instead of aString
for the color parameter. This change will improve type safety and maintain consistency with the rest of your code. -
Method Implementation: In the
RightTriangle
class, thedraw()
method incorrectly labels the shape as 'Rectangle'. Please correct this to 'RightTriangle' to accurately reflect the class functionality.
These changes are important to ensure your code is robust, maintainable, and aligned with the task requirements. Once you've addressed these issues, we can proceed with the approval. 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.
private ColorSupplier supplier = new ColorSupplier(); | ||
private Random random = new Random(); | ||
|
||
public Figure getRundomFigure() { |
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.
There is a typo in the method name getRundomFigure()
. It should be corrected to getRandomFigure()
.
private Random random = new Random(); | ||
|
||
public Figure getRundomFigure() { | ||
String color = supplier.getRandomColor(); |
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 using String
for color, consider using the Color
enum directly to improve type safety and align with the task requirements.
} | ||
|
||
public Figure getDefaultFigure() { | ||
return new Circle(DEFAULT_RADIUS, Color.WHITE.name()); |
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.
When creating the default figure, consider passing the Color.WHITE
enum directly instead of using Color.WHITE.name()
to maintain consistency with the use of enums.
public class IsoscelesTrapezoid extends Figure { | ||
private int bottomBase; | ||
private int topBase; | ||
private int hight; |
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 variable name hight
is misspelled. It should be corrected to height
.
private int topBase; | ||
private int hight; | ||
|
||
public IsoscelesTrapezoid(int bottomBase, int topBase, int hight, String color) { |
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.
Consider using the Color
enum instead of a String
for the color parameter to maintain type safety and consistency with the rest of the code.
|
||
for (int i = 0; i < figures.length; i++) { | ||
if (i < figures.length / 2) { | ||
figures[i] = figureSupplier.getRundomFigure(); |
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.
There is a typo in the method call getRundomFigure()
. It should be corrected to getRandomFigure()
to match the method name in the FigureSupplier
class.
private int length; | ||
private int width; | ||
|
||
public Rectangle(int length, int width, String color) { |
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.
Consider using the Color
enum instead of a String
for the color parameter to maintain type safety and consistency with the rest of the code.
} | ||
|
||
@Override | ||
public 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 draw()
method incorrectly labels the shape as 'Rectangle'. It should be corrected to 'RightTriangle'.
private int legA; | ||
private int legB; | ||
|
||
public RightTriangle(int legA, int legB, String color) { |
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.
Consider using the Color
enum instead of a String
for the color parameter to maintain type safety and consistency with the rest of the code.
public class Square extends Figure { | ||
private int side; | ||
|
||
public Square(int side, String color) { |
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.
Consider using the Color
enum instead of a String
for the color parameter to maintain type safety and consistency with the rest of the code.
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 job on your submission! 🎉 Your code implementation mostly meets the task requirements, and you've made significant progress. Here are a few points to consider for improvement:
-
Typo Corrections:
- In the
IsoscelesTrapezoid
class, ensure that the field and parameter namehight
is corrected toheight
throughout the class, including the constructor and thedraw()
method. This will enhance clarity and correctness. - In the
FigureSupplier
class, the method namegetRundomFigure()
has been corrected togetRandomFigure()
, which is great for consistency.
- In the
-
Area Calculation:
- Double-check the
getArea()
method in theIsoscelesTrapezoid
class to ensure it uses the correct formula:((bottomBase + topBase) / 2) * height
.
- Double-check the
-
Code Readability:
- Consider using separate variables for complex expressions passed to constructors to improve code readability, as suggested in the checklist.
Your efforts are commendable, and these adjustments will help you refine your skills further. Keep up the good work, and make sure to address these points in future projects to avoid similar issues. Happy coding! 😊
✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨
private ColorSupplier supplier = new ColorSupplier(); | ||
private Random random = new Random(); | ||
|
||
public Figure getRandomFigure() { |
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.
There is a typo in the method name getRundomFigure()
. It should be corrected to getRandomFigure()
to ensure consistency and avoid confusion.
case 0 -> new Circle(randomSide, color); | ||
case 1 -> new IsoscelesTrapezoid(randomSide, randomSide, randomSide, color); | ||
case 2 -> new Rectangle(randomSide, randomSide, color); | ||
case 3 -> new RightTriangle(randomSide, randomSide, color); | ||
case 4 -> new Square(randomSide, color); |
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.
Consider creating separate variables for expressions passed to constructors for better code readability, as suggested in the checklist.
public class IsoscelesTrapezoid extends Figure { | ||
private int bottomBase; | ||
private int topBase; | ||
private int hight; |
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.
There is a typo in the field name hight
. It should be corrected to height
to maintain clarity and correctness.
public IsoscelesTrapezoid(int bottomBase, int topBase, int hight, Color color) { | ||
this.bottomBase = bottomBase; | ||
this.topBase = topBase; | ||
this.hight = hight; |
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.
Ensure that the parameter name hight
is corrected to height
in the constructor as well.
|
||
@Override | ||
public double getArea() { | ||
return ((bottomBase + topBase) / 2) * hight; |
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.
Ensure that the calculation in getArea()
is correct according to the formula for the area of an isosceles trapezoid: ((bottomBase + topBase) / 2) * height
.
@Override | ||
public void draw() { | ||
System.out.println("IsoscelesTrapezoid, area: " + getArea() + " sq. units, bottomBase: " | ||
+ bottomBase + " units, topBase: " + topBase + " units, hight: " + hight |
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.
Ensure that the field name hight
is corrected to height
in the draw()
method as well.
} | ||
|
||
@Override | ||
public 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.
Ensure that the draw()
method correctly labels the shape as 'RightTriangle'.
… interfaces and implemented methods.