diff --git a/README.md b/README.md index 00bbde2294..b106b551be 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # jv-oop-advanced -__Solve the task using OOP principles__ +### Solve the task using OOP principles Task: @@ -9,27 +9,27 @@ You need to create corresponding classes for them(`Square`, `Rectangle`, `RightT All figures have - **state** - all figures have `color`, but each figure type can also have one or several unique properties (`radius` for circle, `firstLeg` and `secondLeg` for right triangle, and so on). -- **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). +- **behavior** - 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 the toString() method for this). -Think where you should declare these fields and methods: top level class / interface / bottom level classes. +Think where you should declare these fields and methods: top-level class/interface / bottom-level classes. -In the `main()` method we need to create an array of figures (the size of array can be 3 or 6, it doesn't matter). +In the `main()` method we need to create an array of figures (the size of the array can be 3 or 6, it doesn't matter). **The first half** of figures in this array should be generated with random parameters. For this purpose create two more classes: - `ColorSupplier` with `public String getRandomColor()` method - for generating random color, -- and `FigureSupplier` with `public Figure getRandomFigure()` method - for generating figure with random properties. +- and `FigureSupplier` with the `public Figure getRandomFigure()` method - for generating figures with random properties. -**The other half** of figures should have the same, default parameters. +**The other half** of the figures should have the same, default parameters. For this purpose create a new method in the `FigureSupplier` class: -- `public Figure getDefaultFigure()` - this method should always return white circle with radius 10. +- `public Figure getDefaultFigure()` - this method should always return a white circle with a radius of 10. After generating the array, we need to display the entire list of objects that we have, for example: ``` - Figure: square, area: 25.0 sq.units, side: 5 units, color: blue - Figure: triangle, area: 12.5 sq.units, firstLeg: 7 units, secondLeg: 5 units, color: yellow + Figure: square, area: 25.0 sq. units, side: 5 units, color: blue + Figure: triangle, area: 12.5 sq. units, firstLeg: 7 units, secondLeg: 5 units, color: yellow ``` -#### [Try to avoid these common mistakes, while solving task](https://mate-academy.github.io/jv-program-common-mistakes/java-core/abstract-class-interface/oop-advanced) +#### [Try to avoid these common mistakes, while solving task](./checklist.md) diff --git a/checklist.md b/checklist.md index 3ac08c512f..a0b2492755 100644 --- a/checklist.md +++ b/checklist.md @@ -1,9 +1,9 @@ ## Common mistakes (jv-oop-advanced) -#### Don't begin class or method implementation with empty line. +#### Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :) -#### Don't use abstract classes to set behaviour for classes +#### Don't use abstract classes to set behavior for classes Abstract classes and interfaces have different use cases. Try to figure out when to use both in this task by yourself. If you're blocked [this](https://stackoverflow.com/a/479168) may give you a hint. @@ -19,8 +19,8 @@ public interface AreaCalculator { } ``` -#### Don't put all behaviour into a single interface if the methods are conceptually different from each other. -All our classes and interfaces should have a single purpose - `draw()` and `getArea()` methods are not conceptually close to each other. +#### Don't put all behavior into a single interface if the methods are conceptually different from each other. +All our classes and interfaces should have a single purpose - the `draw()` and `getArea()` methods are not conceptually close to each other. #### You can pass random values to the constructor of a figure instead of generating them inside figure classes. Let's generate random values in `FigureSupplier`. @@ -74,8 +74,8 @@ public class FigureSupplier { } ``` -#### Creating a figure, don't pass expressions in constructor. -Create separate variables and pass them for better code readability. +#### Creating a figure, don't pass expressions in the constructor. +Create separate variables and pass them on for better code readability. * Bad example: ``` Square square = new Square(random.nextInt(10) + 1); @@ -85,7 +85,7 @@ Square square = new Square(random.nextInt(10) + 1); Static methods are in general a bad practice. Let's better create an instance of a class which method you want to call. #### Don't extend your `Main/Application` class from `FigureSupplier` or `ColorSupplier`. -To be able to call non-static method, we just need to create an instance of the class: +To be able to call the non-static method, we just need to create an instance of the class: ``` FigureSupplier figureSupplier = new FigureSupplier(); Figure randomFigure = figureSupplier.getRandomFigure(); @@ -95,7 +95,7 @@ Figure randomFigure = figureSupplier.getRandomFigure(); Let's do it only once - before the loop starts. #### Don't return `null` from a method. -Returning `null` from a method is a bad practice. If you use switch-case in your solution, you may just put the last possible option in the `default` case. +Returning `null` from a method is a bad practice. If you use a `switch case construction` in your solution, you may just put the last possible option in the `default` case. #### Use only eng in messages/code: Try not to use ukr/ru messages in `toString()` or `System.out.println()` statements. @@ -103,7 +103,7 @@ We want to make our code universal and consistent. #### Use name() for getting String representation of enum constants -Don't use `toString()` or `String.valueOf()`(it will call `toString()` under the hood) for getting `String` representation of enum constants. +Don't use `toString()` or `String.valueOf()`(it will call `toString()` under the hood) for getting the `String` representation of enum constants. `toString()` is common for all enum constants. If you override this method like below: ```` @Override @@ -111,8 +111,8 @@ Don't use `toString()` or `String.valueOf()`(it will call `toString()` under the return "default"; } ```` -then for every constant `toString()` will be returning `default`, that's not ok. So it's better to use standard method of enum `name()` -that will be returning always `String` representation of concrete enum constant. +then for every constant `toString()` will be returning `default`, that's not ok. So it's better to use the standard method of enum `name()` +that will be returning always `String` representation of the concrete enum constant. #### Write informative messages when you commit code or open a PR. -Bad example of commit/PR message: `done`/`fixed`/`commit`/`solution`/`added homework`/`my solution` and other one-word, abstract or random messages. +Bad examples of commit/PR messages: `done`/`fixed`/`commit`/`solution`/`added homework`/`my solution` and other one-word, abstract or random messages. diff --git a/pom.xml b/pom.xml index 930785c885..0f8dd56657 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ 1.0-SNAPSHOT - 11 + 17 UTF-8 UTF-8 3.1.1 @@ -31,7 +31,7 @@ org.apache.maven.plugins maven-checkstyle-plugin - 3.1.1 + 3.3.0 compile