-
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
make task #1311
base: master
Are you sure you want to change the base?
make task #1311
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.
Before you create PR with your homework, you need to go through the checklist under the task and correct all the points described there. The mentor will not check the work until the checklist points are corrected
this.radius = radius; | ||
setColor(color); | ||
getArea(); |
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.
this.radius = radius; | |
setColor(color); | |
getArea(); | |
super(color); | |
this.radius = radius; |
|
||
public class ColorSupplier { | ||
public String getRandomColor() { | ||
Random rand = new Random(); |
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.
refactor variable to final
System.out.println("Circle{" + "radius=" + radius | ||
+ ", color='" + getColor() + '\'' + ", area=" + getArea() + '}'); | ||
return ""; |
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.
System.out.println("Circle{" + "radius=" + radius | |
+ ", color='" + getColor() + '\'' + ", area=" + getArea() + '}'); | |
return ""; | |
return "Circle{" + "radius=" + radius | |
+ ", color='" + getColor() + '\'' + ", area=" + getArea() + '}'; |
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.
behaviour - we can obtain the area of any figure and are able to draw it. To 'draw' means to print out all information about a figure using System.out.println() (you shouldn't override toString() method for this)
.
|
||
public class ColorSupplier { | ||
private final Random rand = new Random(); | ||
private final String[] colors = new String[]{"white", "black", "blue", "red"}; |
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.
make Color enum
|
||
public Figure getRandomFigure() { | ||
String randomFigure = listFigure[random.nextInt(listFigure.length)]; | ||
int randomRange = 100; |
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.
should be class level constant.
randomRange
is misleading name
System.out.println("IsoscelesTrapezoid{" + "upSide=" + upSide | ||
+ ", downSide=" + downSide | ||
+ ", height=" + height + ", color='" | ||
+ getColor() + '\'' + ", area=" + getArea() + '}'); |
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.
behaviour - we can obtain the area of any figure and are able to draw it. To 'draw' means to print out all information about a figure using System.out.println() (you shouldn't override toString() method for this).
figures[2] = new Circle("white", 10); | ||
figures[3] = new Square("black", 5); | ||
for (Figure figure : figures) { | ||
figure.toString(); |
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 adding interface instead of overriding toString
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.
Before you create PR with your homework, you need to go through the checklist under the task and correct all the points described there.
white, | ||
black, |
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.
uppercase
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.
import java.util.Random; | ||
|
||
public class FigureSupplier { | ||
private final int maxNumber = 100; |
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.
Circle, | ||
Square, | ||
Rectangle, | ||
RightTriangle, | ||
IsoscelesTrapezoid |
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.
uppercase
public class Circle extends Figure { | ||
private final int radius; | ||
|
||
public Circle(Color color,int radius) { |
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 should be a space after the comma in the parameters list of the constructor.
package core.basesyntax; | ||
|
||
public class Square extends Figure { | ||
private final double side; |
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.
this fields is marked as 'final' which means that it can't be changed after it's initialized. This is okay if you will never need to change this value, but if you want your objects to be mutable, you should remove the 'final' keyword.
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.
This object is designed to be immutable, which does not change after it is created. In fact, I should have made the shape classes themselves final (Circle, Square and others).
import java.util.Random; | ||
|
||
public class FigureSupplier { | ||
public static final int MAX_NUMBER = 100; |
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 MAX_NUMBER constant could be private as it's not used outside of this class.
|
||
public class FigureSupplier { | ||
public static final int MAX_NUMBER = 100; | ||
private final ColorSupplier colorSupplier = new ColorSupplier(); |
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 colorSupplier object could be static because its method is stateless, and it would be more efficient to have only one instance of ColorSupplier for all FigureSupplier objects.
} | ||
|
||
public Figure getDefaultFigure() { | ||
return new Circle(Color.WHITE,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.
public Figure getDefaultFigure() { | ||
return new Circle(Color.WHITE,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.
redundant indent line
package core.basesyntax; | ||
|
||
public class RightTriangle extends Figure { | ||
private final double firstLeg; |
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.
this fields is marked as 'final' which means that it can't be changed after it's initialized. This is okay if you will never need to change this value, but if you want your objects to be mutable, you should remove the 'final' keyword.
package core.basesyntax; | ||
|
||
public class IsoscelesTrapezoid extends Figure { | ||
private final double upSide; |
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.
this fields is marked as 'final' which means that it can't be changed after it's initialized. This is okay if you will never need to change this value, but if you want your objects to be mutable, you should remove the 'final' keyword.
package core.basesyntax; | ||
|
||
public abstract class Figure implements AreaCalculator, FigureDrawer { | ||
private final Color 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.
this field is marked as 'final' which means that it can't be changed after it's initialized. This is okay if you will never need to change this value, but if you want your objects to be mutable, you should remove the 'final' keyword.
package core.basesyntax; | ||
|
||
public class Circle extends Figure { | ||
private final int radius; |
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.
this field is marked as 'final' which means that it can't be changed after it's initialized. This is okay if you will never need to change this value, but if you want your objects to be mutable, you should remove the 'final' keyword.
No description provided.