-
Notifications
You must be signed in to change notification settings - Fork 1.6k
add task solution #1979
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
base: master
Are you sure you want to change the base?
add task solution #1979
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package core.basesyntax; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This violates checklist item: "Don't begin class or method implementation with an empty line." Remove the redundant empty line before the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This violates checklist item: "Don't begin class or method implementation with an empty line." Remove the blank line before the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This file starts the interface implementation with an empty line. This violates the checklist item: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :)" Remove the blank line at line 2 so the interface declaration immediately follows the package statement. |
||
public interface AreaCalculable { | ||
double getArea(); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package core.basesyntax; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a redundant empty line after the package declaration. The checklist requires: "Don't begin class or method implementation with an empty line." Remove this blank line to comply with the style rules. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is an empty line between the package declaration and the class declaration. The checklist requires: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :)" Remove this blank line so the class starts immediately after the package declaration. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This file contains a blank line immediately after the package statement. The checklist requires: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :)" Remove this blank line to comply with the guideline. |
||
public class Calculator { | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a blank line right after the class declaration before the first field. The checklist requires: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :)" Remove this empty line so the first field appears directly after the class opening. |
||
private static final int FIGURE_ARRAY_SIZE = 6; | ||
|
||
public static void main(String[] args) { | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is an empty line immediately after the main method signature. The checklist requires: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :)" Remove this blank line so the method body starts without a leading empty line. |
||
FigureSupplier figureSupplier = new FigureSupplier(); | ||
Figure[] figures = new Figure[FIGURE_ARRAY_SIZE]; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Redundant empty line inside the method before the first loop. The checklist requires removal of redundant empty lines: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :)" Remove this blank line to make the method body more compact. |
||
for (int i = 0; i < figures.length / 2; i++) { | ||
figures[i] = figureSupplier.getRandomFigure(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Potential NullPointerException risk when assigning random figures. You call |
||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Redundant empty line inside the method between the two loops. The checklist requires removal of redundant empty lines: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :)" Remove this blank line to keep the method body tidy. |
||
for (int i = figures.length / 2; i < figures.length; i++) { | ||
figures[i] = figureSupplier.getDefaultFigure(); | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Redundant empty line inside the method before the final loop. The checklist requires removal of redundant empty lines: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :)" Remove this blank line to comply with the style checklist. |
||
for (Figure figure : figures) { | ||
figure.draw(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Calling draw() without guarding against null figures. You iterate |
||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package core.basesyntax; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This file begins with an empty line right after the package declaration. The checklist requires: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :)" Please remove redundant blank lines (e.g., line 2) so the class does not start with an empty line. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is an empty line immediately after the package declaration (and/or before the class body). The checklist says: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :)" Remove the redundant blank line(s) to conform to the style requirement. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This violates the checklist item: "Don't begin class or method implementation with an empty line.\nRemove all redundant empty lines, be careful :)" — remove the blank line after the package declaration so the class starts without an empty line. |
||
public class Circle extends Figure { | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This violates the checklist item: "Don't begin class or method implementation with an empty line.\nRemove all redundant empty lines, be careful :)" — remove the blank line between the class declaration and the |
||
private final double radius; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This violates the checklist item: "Don't begin class or method implementation with an empty line.\nRemove all redundant empty lines, be careful :)" — remove the blank line between the field and the constructor so the constructor starts immediately after fields. |
||
public Circle(String randomColor, double randomRadius) { | ||
super(randomColor); | ||
this.radius = randomRadius; | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This violates the checklist item: "Don't begin class or method implementation with an empty line.\nRemove all redundant empty lines, be careful :)" — remove the blank line before the |
||
@Override | ||
public double getArea() { | ||
return Math.PI * Math.pow(radius, 2); | ||
} | ||
|
||
Comment on lines
+2
to
+16
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are redundant empty lines at and after the top of the file and before class/method bodies (lines 2, 4, 6, 11, 16). This violates the checklist: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :)" Please remove these empty lines so the class and its members start without leading blank lines. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This violates the checklist item: "Don't begin class or method implementation with an empty line.\nRemove all redundant empty lines, be careful :)" — remove the blank line before the |
||
@Override | ||
public void draw() { | ||
System.out.println("Figure: circle, area: " + getArea() | ||
+ " sq. units, radius: " + radius | ||
+ " units, color: " + getColor()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The draw() concatenates |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package core.basesyntax; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's a redundant empty line after the package declaration. The checklist requires: "Don't begin class or method implementation with an empty line." Remove this blank line to comply with the style rules. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove the redundant empty line after the package declaration. The checklist says: "Don't begin class or method implementation with an empty line." Move the enum declaration up so it directly follows the package line. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a blank line immediately after the package declaration. The checklist requires: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :)" Remove this blank line so the enum declaration follows the package line directly. |
||
public enum Color { | ||
YELLOW, | ||
BLUE, | ||
WHITE, | ||
GREEN, | ||
PURPLE, | ||
BLACK, | ||
RED | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package core.basesyntax; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This file begins with a redundant empty line after the package declaration. This violates: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :)" Remove the blank line at line 2 so the import appears immediately after the package declaration. See checklist guidance . There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Violates checklist item: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :)" — there is a blank line immediately after the package statement; remove it. |
||
import java.util.Random; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Violates checklist item: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :)" — there is a blank line after the import statement; remove it. |
||
public class ColorSupplier { | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Violates checklist item: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :)" — there is a blank line immediately after the class declaration (before the first field); remove it. |
||
private final Random random = new Random(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Checklist requires: "All magic numbers in your code should be constants." While |
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Violates checklist item: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :)" — there is a blank line between the field and the method signature; remove it. |
||
public String getRandomColor() { | ||
return Color.values()[random.nextInt(Color.values().length)].name(); | ||
} | ||
|
||
Comment on lines
+2
to
+12
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are redundant empty lines at and after the top of the file and before class members (lines 2, 4, 8, 12). This violates the checklist: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :)" Please remove these empty lines so the class and its members start without leading blank lines. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Violates checklist item: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :)" — there is a blank line before the closing brace of the class; remove it. |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package core.basesyntax; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a redundant empty line after the package declaration. The checklist requires: "Don't begin class or method implementation with an empty line." Remove this blank line to comply with the style rules. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a redundant empty line at line 2 (immediately after the package declaration). This violates the checklist: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :)" Remove that blank line so the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a blank line immediately after the package declaration. The checklist requires: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :)" Remove this blank line so the |
||
public interface Drawable { | ||
void draw(); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package core.basesyntax; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Redundant empty line after the package declaration. The checklist requires: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :)" Remove this blank line so the class declaration follows the package declaration directly. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is an empty line immediately before the class declaration. This violates the checklist instruction: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :)". Remove the blank line at line 2 before the class definition. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Violates checklist item: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :)" — there is a blank line immediately after the package statement; remove it. |
||
public abstract class Figure implements Drawable, AreaCalculable { | ||
private final String color; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Redundant empty line between the field declaration and the constructor. Remove this blank line to comply with the checklist requirement to avoid starting class/method blocks with empty lines. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Violates checklist item: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :)" — there is a blank line between the field declaration and the constructor; remove it so the constructor starts without a leading empty line. |
||
public Figure(String color) { | ||
this.color = color; | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Redundant empty line between constructor and getColor() method. Remove this blank line to follow the style guideline in the checklist. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Violates checklist item: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :)" — there is a blank line between the constructor and the getColor() method; remove it so the method starts immediately after the constructor. |
||
public String getColor() { | ||
return color; | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Redundant empty line between getColor() method and the abstract getArea declaration. Remove this blank line to comply with the checklist style rules. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Violates checklist item: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :)" — there is a blank line between getColor() and the abstract getArea() declaration; remove it. |
||
public abstract double getArea(); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Redundant empty line between getArea() and draw() abstract declarations. Remove this blank line to follow the checklist guidance on redundant empty lines. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Violates checklist item: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :)" — there is a blank line between getArea() and draw() declarations; remove it. |
||
public abstract void draw(); | ||
Comment on lines
+2
to
+16
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are redundant empty lines at lines 2, 5, 9, 13, and 15. This violates the checklist: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :)" Please remove these empty lines so the class and its members start without leading blank lines. |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package core.basesyntax; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Violates checklist: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :)" — remove this blank line after the package statement. |
||
import java.util.Random; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Violates checklist: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :)" — remove this blank line after the import statement. |
||
public class FigureSupplier { | ||
private static final int FIGURE_COUNT = 5; | ||
private static final double MIN_DIMENSION = 1; | ||
private static final double MAX_DIMENSION = 10; | ||
private static final double DEFAULT_RADIUS = 10; | ||
private static final String DEFAULT_COLOR = Color.WHITE.name(); | ||
private final Random random = new Random(); | ||
private final ColorSupplier colorSupplier = new ColorSupplier(); | ||
//Circle | ||
private final double radius = random.nextDouble(MIN_DIMENSION, MAX_DIMENSION); | ||
//Trapezoid | ||
private final double firstLegTrapezoid = random.nextDouble(MIN_DIMENSION, MAX_DIMENSION); | ||
private final double secondLegTrapezoid = random.nextDouble(MIN_DIMENSION, MAX_DIMENSION); | ||
private final double heightTrapezoid = random.nextDouble(MIN_DIMENSION, MAX_DIMENSION); | ||
//Square | ||
private final double side = random.nextDouble(MIN_DIMENSION, MAX_DIMENSION); | ||
//Triangle | ||
private final double firstLegTriangle = random.nextDouble(MIN_DIMENSION, MAX_DIMENSION); | ||
private final double secondLegTriangle = random.nextDouble(MIN_DIMENSION, MAX_DIMENSION); | ||
//Rectangle | ||
private final double widthRectangle = random.nextDouble(MIN_DIMENSION, MAX_DIMENSION); | ||
private final double heightRectangle = random.nextDouble(MIN_DIMENSION, MAX_DIMENSION); | ||
Comment on lines
+14
to
+26
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This violates the checklist instruction: "Creating a figure, don't pass expressions in the constructor. Create separate variables and pass them on for better code readability." Random dimension values are declared as class-level final fields and computed once at object construction, so every call to getRandomFigure() will reuse the same numeric values. Move generation of random values into getRandomFigure() as local variables (e.g., double radius = random.nextDouble(MIN_DIMENSION, MAX_DIMENSION);) and then pass those locals to the Figure constructors. See the fields declared here: radius, firstLegTrapezoid, secondLegTrapezoid, heightTrapezoid, side, firstLegTriangle, secondLegTriangle, widthRectangle, heightRectangle. |
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Violates checklist: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :)" — remove this blank line that sits between the field declarations and the getRandomFigure() method (keep class members compact). |
||
public Figure getRandomFigure() { | ||
switch (random.nextInt(FIGURE_COUNT)) { | ||
case 0 -> { | ||
return new Circle(colorSupplier.getRandomColor(), radius); | ||
} | ||
case 1 -> { | ||
return new Rectangle(colorSupplier.getRandomColor(), | ||
widthRectangle, heightRectangle); | ||
} | ||
case 2 -> { | ||
return new RightTriangle(colorSupplier.getRandomColor(), | ||
firstLegTriangle, secondLegTriangle); | ||
} | ||
case 3 -> { | ||
return new Square(colorSupplier.getRandomColor(), side); | ||
} | ||
case 4 -> { | ||
return new IsoscelesTrapezoid(colorSupplier.getRandomColor(), | ||
firstLegTrapezoid, | ||
secondLegTrapezoid, | ||
heightTrapezoid); | ||
} | ||
default -> { | ||
return getDefaultFigure(); | ||
} | ||
} | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Violates checklist: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :)" — remove this blank line between the end of getRandomFigure() and the start of getDefaultFigure(). |
||
public Figure getDefaultFigure() { | ||
return new Circle(DEFAULT_COLOR, DEFAULT_RADIUS); | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Violates checklist: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :)" — remove this blank line before the class closing brace. |
||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package core.basesyntax; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This violates checklist item: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :)". Remove the blank line after the package declaration so the import/class begins immediately after the package statement. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Redundant empty line at top of file. Remove this blank line so the file does not begin class implementation with an empty line. See checklist: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :)" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This file contains a blank line immediately after the package statement. This violates the checklist: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :)" Remove the blank line so the file does not start with an empty line after the package declaration. |
||
public class IsoscelesTrapezoid extends Figure { | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Redundant empty line inside class (immediately after class declaration). Remove this blank line to comply with the checklist. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a blank line right after the class declaration before the first field. This violates the checklist: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :)" Remove this empty line so the first field appears directly after the class opening. |
||
private final double firstLeg; | ||
private final double secondLeg; | ||
private final double height; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Redundant empty line before constructor. Remove this blank line to comply with the checklist. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is an empty line between the fields and the constructor. This violates the checklist: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :)" Remove this blank line to keep the constructor immediately after the field declarations. |
||
public IsoscelesTrapezoid(String randomColor, double randomBaseA, | ||
double randomBaseB, double randomHeight) { | ||
super(randomColor); | ||
this.firstLeg = randomBaseA; | ||
this.secondLeg = randomBaseB; | ||
this.height = randomHeight; | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Redundant empty line before getArea() method. Remove this blank line to comply with the checklist. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a blank line between the constructor and the overridden getArea() method. This violates the checklist: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :)" Remove this blank line so the method follows immediately after the constructor if no grouping is intended. |
||
@Override | ||
public double getArea() { | ||
return (firstLeg + secondLeg) / 2 * height; | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Redundant empty line before draw() method. Remove this blank line to comply with the checklist. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a blank line between getArea() and the overridden draw() method. This violates the checklist: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :)" Remove this blank line to keep method implementations compact and consistent. |
||
@Override | ||
public void draw() { | ||
System.out.println("Figure: isosceles trapezoid, area: " + getArea() | ||
+ " sq. units, firstLeg: " + firstLeg | ||
+ " units, secondLeg: " + secondLeg | ||
+ " units, height: " + height | ||
+ " units, color: " + getColor()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The draw() method concatenates |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package core.basesyntax; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This file begins with an empty line after the package declaration. This violates the checklist: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :)". Remove the blank line so the class/imports start directly after the package statement . There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Violates checklist: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :)" — there is a blank line immediately after the package statement; remove it. |
||
public class Rectangle extends Figure { | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Violates checklist: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :)" — there is a blank line immediately after the class declaration before the first field; remove it. |
||
private final double width; | ||
private final double height; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Violates checklist: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :)" — there is a blank line between field declarations and the constructor; remove it. |
||
public Rectangle(String randomColor, double randomWidth, double randomHeight) { | ||
super(randomColor); | ||
this.width = randomWidth; | ||
this.height = randomHeight; | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Violates checklist: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :)" — there is a blank line after the constructor and before the @OverRide; remove it. |
||
@Override | ||
public double getArea() { | ||
return width * height; | ||
} | ||
|
||
Comment on lines
+2
to
+18
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are redundant empty lines at and after the top of the file and before class members (lines 2, 4, 7, 13, 18). This violates the checklist: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :)" Please remove these empty lines so the class and its members start without leading blank lines. (See Rectangle.java: ) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Violates checklist: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :)" — there is a blank line before the second @Override/draw method; remove it. |
||
@Override | ||
public void draw() { | ||
System.out.println("Figure: rectangle, area: " + getArea() | ||
+ " sq. units, width: " + width | ||
+ " units, height: " + height | ||
+ " units, color: " + getColor()); | ||
Comment on lines
+21
to
+24
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In draw() you print the color by concatenating There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line prints the color by concatenating the enum directly: |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package core.basesyntax; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This violates the checklist item: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :)" Remove the blank line immediately after the package declaration so the class declaration follows the package statement without an empty line. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Violates checklist: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :)" — there is a blank line immediately after the package statement. Remove this empty line. |
||
public class RightTriangle extends Figure { | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Violates checklist: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :)" — there is a blank line immediately after the class declaration (before the first field). Remove this empty line so the first field appears directly after the class opening. |
||
private final double firstLeg; | ||
private final double secondLeg; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Redundant empty line between field declarations and the constructor. The checklist requires removal of redundant empty lines: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :)" Remove this blank line to keep the class body compact. |
||
public RightTriangle(String randomColor, double randomLegA, double randomLegB) { | ||
super(randomColor); | ||
this.firstLeg = randomLegA; | ||
this.secondLeg = randomLegB; | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Redundant empty line between the constructor and the getArea() method. The checklist requires removal of redundant empty lines: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :)" Remove this blank line to keep method ordering compact. |
||
@Override | ||
public double getArea() { | ||
return (firstLeg * secondLeg) / 2; | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Redundant empty line between getArea() and the draw() method. The checklist requires removal of redundant empty lines: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :)" Remove this blank line to comply with style guidance. |
||
@Override | ||
public void draw() { | ||
System.out.println("Figure: right triangle, area: " + getArea() | ||
+ " sq. units, firstLeg: " + firstLeg | ||
+ " units, secondLeg: " + secondLeg | ||
+ " units, color: " + getColor()); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package core.basesyntax; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This file contains a redundant empty line after the package declaration. This violates the checklist item: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :)" Remove the blank line so the class declaration follows the package immediately. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This violates the checklist requirement: "Don't begin class or method implementation with an empty line." Remove the empty line between the package declaration and the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Violates checklist item: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :)" — there is a blank line immediately after the package statement; remove it. |
||
public class Square extends Figure { | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Violates checklist item: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :)" — there is a blank line right after the class declaration before the first field; remove it. |
||
private final double side; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Violates checklist item: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :)" — there is a blank line between the field declaration and the constructor; remove it. |
||
public Square(String randomColor, double randomSide) { | ||
super(randomColor); | ||
this.side = randomSide; | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Violates checklist item: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :)" — there is a blank line between the constructor and the @OverRide annotation for getArea(); remove it. |
||
@Override | ||
public double getArea() { | ||
return Math.pow(side, 2); | ||
} | ||
|
||
Comment on lines
+2
to
+16
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are redundant empty lines at and after the top of the file and before class members (lines 2, 4, 6, 11, 16). This violates the checklist: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :)" Please remove these empty lines so the class and its members start without leading blank lines. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Violates checklist item: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :)" — there is a blank line between getArea() method and the @OverRide annotation for draw(); remove it. |
||
@Override | ||
public void draw() { | ||
System.out.println("Figure: square, area: " + getArea() | ||
+ " sq. units, side: " + side | ||
+ " units, color: " + getColor()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The draw() method prints the color by concatenating There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This violates the checklist guidance: "Use name() for getting String representation of enum constants". In |
||
} | ||
} |
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 violates the checklist item: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :)" — remove the empty line between the package declaration and the interface declaration so the interface starts immediately after the package statement.