Skip to content
This repository was archived by the owner on Oct 25, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
b0e8b31
gitignore updated
KrArkadiy Jul 9, 2021
ecddcf0
gitignore updated
KrArkadiy Jul 9, 2021
1df4806
Delete Main.java
KrArkadiy Jul 9, 2021
8a07313
homework_2 done.
KrArkadiy Jul 15, 2021
528cd6f
homework_2 done.
KrArkadiy Jul 15, 2021
e3775d8
homework_2 done.
KrArkadiy Jul 15, 2021
0e704da
homework_2 done.
KrArkadiy Jul 15, 2021
5aa7e96
homework_2 done.
KrArkadiy Jul 15, 2021
4d575f2
README updated
KrArkadiy Jul 15, 2021
d41b249
Update Strategy.java
KrArkadiy Jul 15, 2021
e2a0229
Add UnitBase.java
ArtemNikolaev1 Jul 21, 2021
ede0736
homework_2 corrected
KrArkadiy Jul 25, 2021
579a708
homework_2 corrected
KrArkadiy Jul 25, 2021
385c677
homework_2 corrected
KrArkadiy Jul 25, 2021
14677e0
Merge remote-tracking branch 'origin/feature/KrylosovArkady' into fea…
KrArkadiy Jul 25, 2021
7f07dad
Delete Strategy.java
KrArkadiy Jul 25, 2021
1a6933d
README updated
KrArkadiy Jul 25, 2021
4f3efcd
Update README.md
KrArkadiy Jul 25, 2021
835d06c
Update README.md
KrArkadiy Jul 25, 2021
a186e54
Merge remote-tracking branch 'origin/feature/KrylosovArkady' into fea…
KrArkadiy Jul 25, 2021
42abc65
README updated
KrArkadiy Jul 25, 2021
a9b9d09
package naming corrected
KrArkadiy Jul 25, 2021
4019fa6
Update README.md
KrArkadiy Jul 25, 2021
ad9cbb3
Update README.md
KrArkadiy Jul 25, 2021
c88d878
UnitBase merged
KrArkadiy Jul 25, 2021
3fcf714
Delete UnitBase.java
KrArkadiy Jul 25, 2021
988376a
gitignore updated
KrArkadiy Jul 9, 2021
0f600b5
gitignore updated
KrArkadiy Jul 9, 2021
3e1d995
Delete Main.java
KrArkadiy Jul 9, 2021
231c3e9
homework_2 done.
KrArkadiy Jul 15, 2021
30b783e
homework_2 done.
KrArkadiy Jul 15, 2021
6bba878
homework_2 done.
KrArkadiy Jul 15, 2021
ea7c10a
homework_2 done.
KrArkadiy Jul 15, 2021
566d965
homework_2 done.
KrArkadiy Jul 15, 2021
5d27087
README updated
KrArkadiy Jul 15, 2021
eb00857
homework_2 corrected
KrArkadiy Jul 25, 2021
88d84b0
homework_2 corrected
KrArkadiy Jul 25, 2021
4926d1e
homework_2 corrected
KrArkadiy Jul 25, 2021
cb73022
Update Strategy.java
KrArkadiy Jul 15, 2021
bda3432
README updated
KrArkadiy Jul 25, 2021
5d6eafc
Delete Strategy.java
KrArkadiy Jul 25, 2021
2aed539
Update README.md
KrArkadiy Jul 25, 2021
d84e24c
Update README.md
KrArkadiy Jul 25, 2021
b9dac9f
README updated
KrArkadiy Jul 25, 2021
68fac53
package naming corrected
KrArkadiy Jul 25, 2021
fbecf0b
Update README.md
KrArkadiy Jul 25, 2021
44764f4
Update README.md
KrArkadiy Jul 25, 2021
2756dea
UnitBase merged
KrArkadiy Jul 25, 2021
f9a8a46
Delete UnitBase.java
KrArkadiy Jul 25, 2021
0e076f4
UnitBase merged
KrArkadiy Jul 25, 2021
87529e8
Merge branch 'feature/KrylosovArkady'
KrArkadiy Jul 25, 2021
dcb4e0a
UnitBase merged
KrArkadiy Jul 25, 2021
a54053f
Update UnitBase.java
KrArkadiy Jul 25, 2021
3d8a1fa
homework_2 correction
KrArkadiy Jul 26, 2021
e6a7eea
Merge remote-tracking branch 'origin/feature/KrylosovArkady' into fea…
KrArkadiy Jul 26, 2021
d4ef7cb
homework_2 correction
KrArkadiy Jul 26, 2021
fb46f53
homework_3 correction
KrArkadiy Aug 5, 2021
478cf57
homework_4 realization
KrArkadiy Aug 5, 2021
239bf04
homework_4 realization
KrArkadiy Aug 5, 2021
55c43a8
homework_4 tests realization
KrArkadiy Aug 5, 2021
ab773e1
README updated
KrArkadiy Aug 5, 2021
7f594b2
homework_2,4 fixed.
KrArkadiy Aug 11, 2021
2cf9724
homework 5 done.
KrArkadiy Sep 7, 2021
ab37ecc
homework 6 done.
KrArkadiy Sep 7, 2021
18ae0d6
homework 7 and course project done.
KrArkadiy Sep 22, 2021
2bd2afd
course project fixed
KrArkadiy Sep 23, 2021
fe79848
course project fixed
KrArkadiy Sep 23, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
# Java Core June 2021

## *Nikolaev Artem*
## *Krylosov Arkadiy*

| Number | Solution | Short description
| --- | --- | --- |
| HW1 | [Console printer](https://github.com/NikolaevArtem/Java_Core_June_2021/tree/master/src/main/java/homework_1) | The app that reads input arguments and prints them, until "error" argument |

[Link to markdown giude](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet)
| HW1 | [Console printer](https://github.com/NikolaevArtem/Java_Core_June_2021/tree/feature/KrylosovArkady/src/main/java/homework_1) | The app that reads input arguments and prints them, until "error" argument |
| HW2.1 | [Traffic Light](https://github.com/NikolaevArtem/Java_Core_June_2021/tree/feature/KrylosovArkady/src/main/java/homework_2/traffic_light) | The app that reads input arguments and output, what traffic light color it would be in inputted time. User has an opportunity to enter time in 2 formats |
| HW2.2 | [Pyramid Printer](https://github.com/NikolaevArtem/Java_Core_June_2021/tree/feature/KrylosovArkady/src/main/java/homework_2/pyramid_printer) | The app that reads input arguments and prints a pyramid of "x" according to the entered positive integer|
| HW2.3 | [Random Chars Table](https://github.com/NikolaevArtem/Java_Core_June_2021/tree/feature/KrylosovArkady/src/main/java/homework_2/random_chars_table) | The app that reads input arguments and prints an array and a String of even of odd letters, result depends on chosen strategy|
| HW3 | [Immutable class](https://github.com/NikolaevArtem/Java_Core_June_2021/tree/feature/KrylosovArkady/src/main/java/homework_3) | Example of immutable class|
| HW4.1 | [Custom File Reader](https://github.com/NikolaevArtem/Java_Core_June_2021/tree/feature/KrylosovArkady/src/main/java/homework_4/custom_file_reader) |The app that reads file 3 different ways and print the result into console |
| HW4.2 | [My annotation](https://github.com/NikolaevArtem/Java_Core_June_2021/tree/feature/KrylosovArkady/src/main/java/homework_4/custom_annotation) | My custom annotation that allows to put annotated fields into JSON file|
| HW4.3 | [Singleton](https://github.com/NikolaevArtem/Java_Core_June_2021/tree/feature/KrylosovArkady/src/main/java/homework_4/singleton) |Example of singleton design pattern |
| HW5.1 | [Power of Number](https://github.com/NikolaevArtem/Java_Core_June_2021/tree/feature/KrylosovArkady/src/main/java/homework_5/power_of_number) |The app that raises to the power of input using recursion |
| HW5.2 | [Custom regex matcher](https://github.com/NikolaevArtem/Java_Core_June_2021/tree/feature/KrylosovArkady/src/main/java/homework_5/custom_regex_matcher) |The app that simulate password regex matcher |
| HW6 | [Map problems generator](https://github.com/NikolaevArtem/Java_Core_June_2021/tree/feature/KrylosovArkady/src/main/java/homework_6/map_problems_generator) |Example of problems that may occur if contract of equals & hashCode are not followed and if mutable class if used as a key |
[Link to codingBat](https://codingbat.com/done?user=krylosov.arkady@yandex.ru&tag=8157289593)
[Link to markdown guide](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet)
11 changes: 11 additions & 0 deletions src/main/java/course_project/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package course_project;

import course_project.service.Runner;

public class Main {
public static void main(String[] args) {
Runner runner = new Runner();
Copy link
Owner

Choose a reason for hiding this comment

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

Seems broken:
image
Also, please introduce automatic ship placement

Copy link
Owner

Choose a reason for hiding this comment

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

Also, if input is wrong, the app just shuts down. Really annoying in case you make a typo right before the end :)

Copy link
Owner

Choose a reason for hiding this comment

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

image

Copy link
Owner

Choose a reason for hiding this comment

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

image

Copy link
Owner

Choose a reason for hiding this comment

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

Have you played your own game?)
Sorry, can't approve a this state

runner.run();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package course_project.custom_exceptions;

public class CoordinatesNumber extends Exception{

public CoordinatesNumber() {
super("Number of coordinates don't fit ship length");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package course_project.custom_exceptions;

public class InvalidShip extends Exception {

public InvalidShip() {
super("Invalid place for ship! It should be horizontal, vertical and solid structure");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package course_project.custom_exceptions;

public class PlaceNotFree extends Exception {

public PlaceNotFree() {
super("Invalid place for ship: this place is already occupied by another ship or another ship is too close");
}
}
19 changes: 19 additions & 0 deletions src/main/java/course_project/model/Battlefield.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package course_project.model;

import java.util.Arrays;

public class Battlefield {
private Designation[][] grid;

public Battlefield() {
grid = new Designation[11][11];
for (Designation[] cell : grid) {
Arrays.fill(cell, Designation.EMPTY);
}
}

public Designation[][] getGrid() {
return grid;
}

}
30 changes: 30 additions & 0 deletions src/main/java/course_project/model/Designation.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package course_project.model;

public enum Designation {
SHIP("◾", 0),
FOUR_DECKER("", 4),
THREE_DECKER("", 3),
TWO_DECKER("", 2),
ONE_DECKER("", 1),
HIT("x", 0),
EMPTY("~", 0),
MISS("*", 0),
GAP("o", 0);

private String sign;
private int length;

Designation(String sign, int length) {
this.sign = sign;
this.length = length;
}

@Override
public String toString() {
return sign;
}

public int getLength() {
return length;
}
}
56 changes: 56 additions & 0 deletions src/main/java/course_project/model/Player.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package course_project.model;

import java.io.IOException;
import java.util.Scanner;

public class Player {

private Battlefield myField;
private Battlefield enemyField;
private String name;
private int shipsAmount;

public Player() {
myField = new Battlefield();
enemyField = new Battlefield();
shipsAmount = 10;
}

public void setName(String name) {
this.name = name;
}

public String getName() {
return this.name;
}



public Designation[][] getGrid() {
return myField.getGrid();
}

public Battlefield getField() {
return this.myField;
}

public Battlefield getEnemyField() {
return this.enemyField;
}

public void setMyField(Battlefield myField) {
this.myField = myField;
}

public void setEnemyField(Battlefield enemyField) {
this.enemyField = enemyField;
}

public int getShipsAmount() {
return shipsAmount;
}

public void setShipsAmount(int shipsAmount) {
this.shipsAmount = shipsAmount;
}
}
Loading