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

Home Work solution jv-oop-advanced #1740

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

Conversation

Danila2006
Copy link

Added interface CalculateArea.java, class Circle.java, class ColorSupplier.java, interface Colors.java, interface Drawable.java, class Figure.java, class FigureSupplier.java, interface Figures.java, class IsoscelesTrapezoid.java, class Rectangle.java, class RightTriangle.java, class Square.java; Changed HelloWorld.java

…plier.java, interface Colors.java, interface Drawable.java, class Figure.java, class FigureSupplier.java, interface Figures.java, class IsoscelesTrapezoid.java, class Rectangle.java, class RightTriangle.java, class Square.java; Changed HelloWorld.java
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 pull request! While your implementation is mostly solid, there are a few critical issues that need to be addressed before we can approve it:

  1. Non-English Text in drawFigure() Methods: Several classes (Circle, RightTriangle, Square, IsoscelesTrapezoid, Rectangle) contain non-English text in their drawFigure() methods. It's important to use English for all messages to ensure consistency and universality across the codebase.

  2. Returning null in FigureSupplier: The getRandomFigure() method in the FigureSupplier class returns null in the default case. This is not recommended as it can lead to NullPointerExceptions. Consider handling this case by throwing an exception or returning a default figure.

  3. Use of toString() for Enum Constants: In the ColorSupplier class, replace toString() with name() for getting the string representation of enum constants. This aligns with best practices and ensures reliability.

  4. Hardcoded Pi Value: The Circle class uses a hardcoded value of 3.14 for Pi. Replace this with Math.PI for better precision in calculations.

These changes are necessary to ensure the code meets the core requirements and maintains high quality. Once these issues are resolved, your pull request will be ready for approval. Keep up the great work, and don't hesitate to reach out if you have any questions! 😊

✨ 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 double getS() {
return 3.14 * Math.pow(this.radius, 2);

Choose a reason for hiding this comment

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

Consider using Math.PI instead of 3.14 for better precision in calculating the area of the circle.

Comment on lines 17 to 18
System.out.println("Коло { радіус = " + this.radius + ", площа = "
+ getS() + ", колір - " + getColor() + " }");

Choose a reason for hiding this comment

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

The drawFigure() method contains non-English text. According to the checklist, you should use English for messages to ensure the code is universal and consistent.

public String getRandomColor() {
int index = new Random().nextInt(Colors.values().length);
Colors color = Colors.values()[index];
return color.toString();

Choose a reason for hiding this comment

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

Instead of using toString(), use name() to get the string representation of the enum constant. This is a more reliable method as per the checklist guidelines.

int index = random.nextInt(Figures.values().length);
Figures figure = Figures.values()[index];

switch (figure.toString()) {

Choose a reason for hiding this comment

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

Instead of using toString(), use name() to get the string representation of the enum constant. This is a more reliable method as per the checklist guidelines.

random.nextDouble() * 100,
random.nextDouble() * 100);
default:
return null;

Choose a reason for hiding this comment

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

Returning null from a method is considered a bad practice. Consider handling the default case differently, such as by throwing an exception or returning a default figure.

Comment on lines 21 to 24
System.out.println("Рівнобічна трапеція { основа1 = " + this.base1
+ ", основа2 = " + this.base2
+ ", висота = " + this.height + ", площа = " + getS()
+ "колір - " + getColor() + " }");

Choose a reason for hiding this comment

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

The drawFigure() method contains non-English text. According to the checklist, you should use English for messages to ensure the code is universal and consistent.

Comment on lines 23 to 24
+ ", висота = " + this.height + ", площа = " + getS()
+ "колір - " + getColor() + " }");

Choose a reason for hiding this comment

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

There is a missing space before 'колір'. Ensure proper spacing for readability.

Comment on lines 20 to 21
System.out.println("Прямокутник { сторона1 = " + this.side1 + ", сторона2 = " + this.side2
+ ", площа = " + getS() + ", колір - " + getColor() + " }");

Choose a reason for hiding this comment

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

The drawFigure() method contains non-English text. According to the checklist, you should use English for messages to ensure the code is universal and consistent.

Comment on lines 21 to 24
System.out.println("Прямокутний трикутник { катет1 = " + this.leg1 + ", катет2 = "
+ this.leg2 + ", гіпотенуза = " + this.hypotenusa
+ ", площа = " + getS()
+ ", колір - " + getColor() + " }");

Choose a reason for hiding this comment

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

The drawFigure() method contains non-English text. According to the checklist, you should use English for messages to ensure the code is universal and consistent.

Comment on lines 18 to 19
System.out.println("Квадрат { сторона = " + this.side + ", площа = "
+ getS() + ", колір - " + getColor() + " }");

Choose a reason for hiding this comment

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

The drawFigure() method contains non-English text. According to the checklist, you should use English for messages to ensure the code is universal and consistent.

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.

Review Summary

Great job on addressing the previous issues and aligning your code with the task requirements! 🎉 Your implementation now meets the necessary standards, and the improvements you've made are commendable. Here are some key points and suggestions for further enhancement:

  1. Non-English Text in drawFigure() Methods: You've successfully updated the drawFigure() methods in all relevant classes to use English text, ensuring consistency and universality across the codebase.

  2. Returning null in FigureSupplier: The getRandomFigure() method no longer returns null. Instead, it throws an IllegalStateException in the default case, which is a better practice.

  3. Use of toString() for Enum Constants: The ColorSupplier class now uses name() instead of toString() for getting the string representation of enum constants, aligning with best practices.

  4. Hardcoded Pi Value: The Circle class now uses Math.PI instead of a hardcoded value for Pi, ensuring better precision in calculations.

  5. Loop Condition: Consider using i < 3 instead of i <= 2 for the loop condition in HelloWorld.java to follow the conventional pattern and avoid confusion.

  6. Consistency in Enum Usage: Ensure consistency by using Colors.WHITE.name() instead of Colors.WHITE.toString().

Although there are minor issues, the decision to approve is made to help you move forward with your learning. Please review the comments to further improve your code. Remember, addressing these points will enhance your coding skills and prevent similar issues in the future. Keep up the great work and continue learning from your experiences! 🚀

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

}

public Figure getDefaultFigure() {
return new Circle(Colors.WHITE.toString(), 10);

Choose a reason for hiding this comment

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

Consider using Colors.WHITE.name() instead of Colors.WHITE.toString() for consistency with the rest of the codebase.


for (int i = 0; i <= 2; i++) {

Choose a reason for hiding this comment

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

The loop condition i <= 2 should be i < 3 to avoid confusion and ensure consistency with the typical loop pattern. Both conditions are functionally equivalent here, but using i < 3 is more conventional.

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