-
Notifications
You must be signed in to change notification settings - Fork 1.6k
full implementation of OOP Advanced task #1976
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?
Changes from all commits
56227ac
41c1239
e498069
e6cb3ea
5c6bcd1
ba60659
d170f2f
52e7c01
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,15 @@ | ||
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 class starts 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. This file begins with a 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 the blank line (line 2) so the class declaration follows the package line directly. |
||
public class Application { | ||
public static void main(String[] args) { | ||
FigureSupplier fs = new FigureSupplier(); | ||
Figure[] figures = new Figure[Constant.NUMBER_OF_FIGURES_TO_CREATE]; | ||
for (int i = 0; i < Constant.NUMBER_OF_FIGURES_TO_CREATE / 2; i++) { | ||
figures[i] = fs.getRandomFigure(); | ||
figures[i + Constant.NUMBER_OF_FIGURES_TO_CREATE / 2] = fs.getDefaultFigure(); | ||
Comment on lines
+7
to
+9
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 runtime error — possible null entries in the figures array when NUMBER_OF_FIGURES_TO_CREATE is odd.
Comment on lines
+7
to
+9
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. You use |
||
} | ||
for (Figure figure : figures) { | ||
figure.draw(); | ||
} | ||
} | ||
} |
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 file has an extra blank line immediately after the package declaration. Remove it so the interface declaration follows the package line without an empty line. This violates the code style checklist: "Do not start class or method implementations with an empty line; remove redundant empty lines (see checklist item 1)." 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 item: "Don't begin class or method implementation with an empty line." Remove the blank line so the interface declaration follows the package statement 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. This file violates the checklist item: "Don't begin class or method implementation with an empty line.\nRemove all redundant empty lines, be careful :)" — there is an empty line immediately after the |
||
public interface AreaCalculator { | ||
double getArea(); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
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 immediately after the package declaration. The checklist requires: "Do not start class or method implementations with an empty line; remove redundant empty lines." Please remove the empty line so the class starts directly 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 begins the class with a blank 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 this empty line so the class declaration immediately follows the package line. |
||
public class Circle extends Figure { | ||
private 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. There's an empty line immediately before the constructor. Per 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 constructor starts without a leading empty line. |
||
public Circle(String color, double radius) { | ||
super(color); | ||
this.radius = radius; | ||
area = getArea(); | ||
Comment on lines
+6
to
+9
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. Consider calling |
||
} | ||
|
||
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 an empty line before the getArea() method. This is another violation of 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 method (and its @OverRide) directly follow the previous code. |
||
@Override | ||
public double getArea() { | ||
return Math.PI * radius * radius; | ||
} | ||
|
||
Comment on lines
+5
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 inside the class (lines 5, 11, 16). Per the checklist: "Do not start class or method implementations with an empty line; remove redundant empty lines." Remove these extra empty lines to match the required style.
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. Redundant empty lines found (package -> class/constructors/methods). 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 lines at the top and between members so class and methods start without a leading blank line (currently empty lines at lines 2, 5, 11, 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's an empty line right before the draw() method. This also violates the checklist: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :)" Remove this redundant empty line. |
||
@Override | ||
public void draw() { | ||
System.out.println("Figure: circle, area: " + area + " sq. units, radius: " | ||
+ radius + " units " + "color: " + color.toLowerCase()); | ||
Comment on lines
+19
to
+20
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() println concatenation lacks a comma/separator before the color label, producing output like "... units color: blue". For consistency with the task example and improved readability, include a comma and space before the color label. For example: |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
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 the class implementation with an empty line after the package declaration. This violates the checklist item: "Do not start class or method implementations with an empty line; remove redundant empty lines (see checklist item 1)." Please remove the blank line at line 2 so the class declaration follows the package declaration 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 file contains a redundant empty line right 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 import follows the package immediately. |
||
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. This file contains a redundant empty line between the import and the class 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 this empty line so the class declaration directly follows the import. |
||
public class ColorSupplier { | ||
private static final Colors[] colors = Colors.values(); | ||
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 static final field |
||
private final Random rg = new Random(); | ||
|
||
Comment on lines
+2
to
+8
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 lines found. 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 lines after the package declaration and between imports/class members so the file starts and methods don't begin 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. There's a redundant empty line inside the class before the method. This violates the checklist item: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :)" Remove this blank line so the field declarations and methods are contiguous. |
||
public String getRandomColor() { | ||
return colors[rg.nextInt(Constant.NUMBER_OF_COLORS)].name(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
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 the enum implementation with an empty line immediately after the package declaration. This violates the checklist item: "Do not start class or method implementations with an empty line; remove redundant empty lines (see checklist item 1)." Remove the 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. This violates checklist item: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :)" — remove the empty line after the package declaration so the enum declaration starts immediately after 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 an empty line 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 the blank line so the enum declaration directly follows the package line. |
||
public enum Colors { | ||
WHITE, | ||
BLACK, | ||
RED, | ||
GREEN, | ||
BLUE | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
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. Remove the blank line after the package declaration. This file begins the class implementation with an empty line which violates the checklist item: "Do not start class or method implementations with an empty line; remove redundant empty lines (see checklist item 1)." 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 empty line between the package declaration and the class. This violates the checklist item: "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 begins with a blank line immediately 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 empty line so the class declaration follows the package line without a blank line between them. |
||
public class Constant { | ||
public static final int NUMBER_OF_COLORS = Colors.values().length; | ||
public static final int NUMBER_OF_FIGURES = 5; | ||
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 is missing constants for minimum/maximum bounds used when generating random dimensions. The checklist requires that "All magic numbers in your code should be constants." Add constants such as MIN_DIMENSION and MAX_DIMENSION (double) and use them from FigureSupplier instead of calling Random.nextDouble() without scaling. See checklist: "All magic numbers in your code should be constants." |
||
public static final int DIVISION_FOR_AREA = 2; | ||
public static final int DEFAULT_CIRCLE_RADIUS = 10; | ||
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. You have DEFAULT_CIRCLE_RADIUS (10) which is required, but the project also needs a constant for the default color. The task states: "public Figure getDefaultFigure() - this method should always return a white circle with a radius of 10." Add a constant like DEFAULT_COLOR = "white" (or define and document using Colors.WHITE.name()) so the default figure color is driven by a constant rather than a literal elsewhere. Quote from description: "public Figure getDefaultFigure() - this method should always return a white circle with a radius of 10." |
||
public static final int NUMBER_OF_FIGURES_TO_CREATE = 6; | ||
public static final int MAX_DIMENSION = 10; | ||
public static final int MIN_DIMENSION = 2; | ||
public static final String DEFAULT_COLOR = "white"; | ||
} |
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. Style violation — remove leading empty line. This file begins the interface implementation with an 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 :)" Please delete line 2 so the interface declaration follows the package declaration 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. Remove the empty line between the package declaration and the interface declaration. This violates the checklist item: "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. There's an empty line 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 the blank line so the interface declaration directly follows the package line. |
||
public interface Drawer { | ||
void draw(); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
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 the class implementation with an 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 :)" Please remove the blank line at line 2 so the class declaration follows the package declaration 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. Remove the leading 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 :)". The class should start immediately after 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. Remove this leading empty line to comply with the checklist: "Don't begin class or method implementation with an empty line." |
||
public abstract class Figure implements Drawer, AreaCalculator { | ||
protected String color; | ||
protected double area; | ||
|
||
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 between field declarations and the constructor. This also violates: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :)". Start the constructor immediately after the field declarations. 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 unnecessary empty line before the constructor. Remove this blank line so the constructor immediately follows the field declarations, per the checklist requirement to avoid leading empty lines in classes and methods. |
||
public Figure(String color) { | ||
this.color = color; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
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 item: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines". Please remove the blank line so the class declaration follows the package line immediately . |
||
import java.util.Random; | ||
|
||
public class FigureSupplier { | ||
private final Random rg = new Random(); | ||
private final ColorSupplier cs = new ColorSupplier(); | ||
Comment on lines
+6
to
+7
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 code correctly uses a default branch in the switch so the method never returns null (good). Also |
||
|
||
public Figure getRandomFigure() { | ||
int randomNumber = rg.nextInt(Constant.NUMBER_OF_FIGURES); | ||
String randomColor = cs.getRandomColor(); | ||
double range = Constant.MAX_DIMENSION - Constant.MIN_DIMENSION; | ||
double radius = Constant.MIN_DIMENSION + rg.nextDouble(range); | ||
double width = Constant.MIN_DIMENSION + rg.nextDouble(range); | ||
double height = Constant.MIN_DIMENSION + rg.nextDouble(range); | ||
double firstLeg = Constant.MIN_DIMENSION + rg.nextDouble(range); | ||
double secondLeg = Constant.MIN_DIMENSION + rg.nextDouble(range); | ||
double top = Constant.MIN_DIMENSION + rg.nextDouble(range); | ||
Comment on lines
+13
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. This code uses |
||
switch (randomNumber) { | ||
case 0: { | ||
return new Circle(randomColor, radius); | ||
} | ||
case 1: { | ||
return new Rectangle(randomColor, width, height); | ||
} | ||
case 2: { | ||
return new RightTriangle(randomColor, firstLeg, secondLeg); | ||
} | ||
case 3: { | ||
return new Square(randomColor, width); | ||
} | ||
default: { | ||
return new IsoscelesTrapezoid(randomColor,width, height, top); | ||
} | ||
} | ||
} | ||
|
||
Comment on lines
+2
to
+37
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 redundant empty lines. Fix per checklist: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :)" Remove the blank lines so the class and methods do not start with an empty line (examples in this file at lines 2, 4, 8, 37). |
||
public Figure getDefaultFigure() { | ||
return new Circle(Constant.DEFAULT_COLOR, Constant.DEFAULT_CIRCLE_RADIUS); | ||
Comment on lines
+38
to
+39
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. Default figure color usage: getDefaultFigure() calls |
||
} | ||
} |
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 the class implementation with an 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 at line 2 so the class declaration follows the package declaration 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 file begins with a redundant empty line immediately after the package declaration. Please remove it. This violates the checklist item: "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 begins with a blank line 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 the empty line so the class declaration follows the package line without a blank line between them. |
||
public abstract class FigureWithBottomAndHeight extends Figure { | ||
protected double width; | ||
protected 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. There is an empty line right before the constructor (line 6). Remove this leading empty line so the constructor begins without a blank line. This violates the checklist item: "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. There's a redundant empty line between the field declarations and the constructor. Per 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 constructor follows the fields directly. |
||
public FigureWithBottomAndHeight(String color, double width, double height) { | ||
super(color); | ||
this.width = width; | ||
this.height = 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. Remove the redundant empty line at line 12 (before the closing brace). The checklist requests removing redundant empty lines: "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. There's a redundant empty line before the class closing brace. Remove this blank line as requested by the checklist: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :)" |
||
} |
This file was deleted.
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. Leading 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 declaration follows the package line 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. Remove the empty line right 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 :)". Start the class declaration 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. This file begins with a blank line 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 the blank line so the class declaration follows the package line without an empty line. |
||
public class IsoscelesTrapezoid extends FigureWithBottomAndHeight { | ||
private double top; | ||
|
||
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 between the field declaration and the constructor. The checklist requires not to begin class/method implementations with an empty line. Keep class members compact and 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. There is a redundant blank line before the constructor. Per 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 constructor starts without a leading blank line. |
||
public IsoscelesTrapezoid(String color, double bottom, double heigh, double top) { | ||
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 identifier and constructor parameter |
||
super(color, bottom, heigh); | ||
Comment on lines
+6
to
+7
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. Constructor parameter uses the misspelled
Comment on lines
+6
to
+7
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. Constructor parameter is misspelled: |
||
this.top = top; | ||
area = getArea(); | ||
} | ||
Comment on lines
+6
to
+10
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. Constructor parameter is named |
||
|
||
@Override | ||
public double getArea() { | ||
return (width + top) * height / Constant.DIVISION_FOR_AREA; | ||
} | ||
|
||
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 before the end of the class/methods. The checklist forbids leading empty lines in class/method implementations; tidy up any extra blank lines (e.g., line 16).
Comment on lines
+11
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 extra blank lines before methods (lines around getArea/draw). Remove redundant empty lines to comply with: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :)" |
||
@Override | ||
public void draw() { | ||
System.out.println("Figure: isosceles trapezoid, area: " + area + " sq. units, width: " | ||
+ width + " units, height: " + height + " top: " + top + " color: " | ||
+ color.toLowerCase()); | ||
Comment on lines
+18
to
+21
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() println concatenation lacks commas/separators before |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
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 the class implementation with an 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 :)" Please remove the blank line so the class declaration immediately 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. 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 declaration immediately follows the package line. |
||
public class Rectangle extends FigureWithBottomAndHeight { | ||
|
||
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 here before the constructor. Remove it to comply with the checklist: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :)" |
||
public Rectangle(String color, double bottom, double heigh) { | ||
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 Rectangle constructor uses parameters named 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. Constructor parameter is named |
||
super(color, bottom, heigh); | ||
Comment on lines
+5
to
+6
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. Constructor parameter
Comment on lines
+5
to
+6
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. Constructor parameter |
||
area = 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. There is an extra empty line before the getArea()/@OverRide block. Remove this blank line per the checklist: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :)" |
||
@Override | ||
public double getArea() { | ||
return width * 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. There is an extra empty line before the draw() method. Remove this blank line per the checklist: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :)" |
||
@Override | ||
public void draw() { | ||
System.out.println("Figure: rectangle, area: " + area + " sq. units, width: " | ||
+ width + " units, height: " + height + " color: " + color.toLowerCase()); | ||
Comment on lines
+17
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. The draw() output concatenation is missing a comma/clear separator before the color field which makes the output differ from the example. The task requires printing all figure info using System.out.println(). Please standardize the output to include commas and units, e.g.: |
||
} | ||
} |
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. This file begins with an empty line between the package and the class declaration. The checklist explicitly requires: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :)" Please remove the redundant 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. Leading 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". Please remove the blank line so the class declaration immediately follows the package line. See checklist for 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. Remove the empty line 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 :)" 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 blank line after the package declaration 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 class declaration immediately follows the package line. |
||
public class RightTriangle extends Figure { | ||
private double firstLeg; | ||
private 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. Remove the redundant empty line between the field declarations and the constructor. The checklist requires not to begin method/class implementations with an empty line (same rule as above) 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 here before the constructor. Remove it per the checklist: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :)" |
||
public RightTriangle(String color, double firstLeg, double secondLeg) { | ||
super(color); | ||
this.firstLeg = firstLeg; | ||
this.secondLeg = secondLeg; | ||
area = 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. Remove the redundant empty line between the constructor and the overridden methods. The checklist forbids leading empty lines before methods — tidy up this blank line (line 13). 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 before the @Override/getArea block. Remove this blank line to comply with the checklist. |
||
@Override | ||
public double getArea() { | ||
return firstLeg * secondLeg / Constant.DIVISION_FOR_AREA; | ||
} | ||
|
||
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 before the draw() override. Methods should not start with an empty line (checklist). Remove the blank at line 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 is a redundant empty line before the draw() method. Remove this blank line to comply with the checklist. |
||
@Override | ||
public void draw() { | ||
System.out.println("Figure: right triangle, area: " + area + " sq. units, firstLeg: " | ||
+ firstLeg + " units, secondLeg: " + secondLeg + " color: " + color.toLowerCase()); | ||
Comment on lines
+21
to
+22
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() output concatenation is missing a comma/clear separator before the color field. The task requires printing all figure information in a readable format (see description). Update the println to include a comma and a space before the color and ensure 'units' and 'sq. units' are present. Example: |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
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. The checklist explicitly states: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :)" Please remove the redundant blank line at the top of the file 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. Style violation — remove the leading empty line after the package declaration. The checklist states: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines." Please delete the blank line so the class declaration follows the package line immediately. (See Square.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. 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 directly after the package declaration so the class starts 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. This file contains a blank line immediately after the package declaration. Fix per 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 class declaration follows the package line without a blank line. |
||
public class Square extends Figure { | ||
private 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. 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 between the field declaration and the constructor so the constructor does not begin 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 a redundant empty line before the constructor. 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 constructor starts immediately. |
||
public Square(String color, double side) { | ||
super(color); | ||
this.side = side; | ||
area = 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. 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 before the getArea() method so the method does not begin 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 before the 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 starts without a leading empty line. |
||
@Override | ||
public double getArea() { | ||
return side * 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. 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 before the draw() method so the method does not begin 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 before the draw() method. Per 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 draw() begins immediately. |
||
@Override | ||
public void draw() { | ||
System.out.println("Figure: square, area: " + area + " sq. units, side: " | ||
+ side + " units, color: " + color.toLowerCase()); | ||
} | ||
} |
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.
Style violation — remove leading empty line.
This file begins the class implementation with an empty line directly after the package declaration. This violates the checklist item: "Do not start class or method implementations with an empty line; remove redundant empty lines (see checklist item 1)."
Suggestion: delete the empty line at line 2 so the class declaration follows the package declaration immediately.