diff --git a/out/production/MyWayJava/Main.class b/out/production/MyWayJava/Main.class deleted file mode 100644 index d52786f..0000000 Binary files a/out/production/MyWayJava/Main.class and /dev/null differ diff --git a/src/hw/one/DiamondBuilder.java b/src/hw/one/DiamondBuilder.java new file mode 100644 index 0000000..82d4335 --- /dev/null +++ b/src/hw/one/DiamondBuilder.java @@ -0,0 +1,33 @@ +package hw.one; + +public class DiamondBuilder { + public static void drawDiamond(int givenNum) { + int stars = 1; + int space = givenNum - stars; + + for (int i = 0; i <= givenNum / 2; i++) { + for (int j = space; j > 0; j--) { + System.out.print(" "); + } + for (int k = 0; k < stars; k++) { + System.out.print("*"); + } + stars += 2; + space--; + System.out.println(); + } + stars -= 2; + space++; + for (int i = 0; i <= givenNum / 2; i++) { + stars -= 2; + space++; + for (int j = 0; j < space; j++) { + System.out.print(" "); + } + for (int k = 0; k < stars; k++) { + System.out.print("*"); + } + System.out.println(); + } + } +} diff --git a/src/hw/one/GameScore.java b/src/hw/one/GameScore.java new file mode 100644 index 0000000..faad4ee --- /dev/null +++ b/src/hw/one/GameScore.java @@ -0,0 +1,12 @@ +package hw.one; + +public class GameScore { + public static int GameForecastCalculator(int teamAscore, int teamBscore, int teamAscoreGuess, int teamBscoreGuess) { + + return ((teamAscore == teamAscoreGuess && teamBscore == teamBscoreGuess) ? + 2:((teamAscore > teamBscore && teamAscoreGuess > teamBscoreGuess) + || (teamAscore < teamBscore && teamAscoreGuess < teamBscoreGuess) + || (teamAscore == teamBscore && teamAscoreGuess == teamBscoreGuess) ? + 1: 0)); + } +} diff --git a/src/hw/one/Main.java b/src/hw/one/Main.java new file mode 100644 index 0000000..0635742 --- /dev/null +++ b/src/hw/one/Main.java @@ -0,0 +1,19 @@ +package hw.one; + +public class Main { + public static void main(String[] args) { + //Test Diamond: + DiamondBuilder.drawDiamond(7); + //Test GameScore: + System.out.println(GameScore.GameForecastCalculator(2, 1, + 2, 1)); + System.out.println(GameScore.GameForecastCalculator(1, 1, + 3, 3)); + System.out.println(GameScore.GameForecastCalculator(2, 1, + 1, 4)); + //Test PowNumber: + System.out.println(PowNumber.sqrtNum(4)); + System.out.println(PowNumber.cubeNum(4)); + System.out.println(PowNumber.powNum(4,4)); + } +} diff --git a/src/hw/one/PowNumber.java b/src/hw/one/PowNumber.java new file mode 100644 index 0000000..9d4903b --- /dev/null +++ b/src/hw/one/PowNumber.java @@ -0,0 +1,25 @@ +package hw.one; + +public class PowNumber { + public static double sqrtNum(int number) { + return number * number; + } + + public static double cubeNum(int number) { + return number * number * number; + } + + public static double powNum(int number, int pow) { + double result = 1; + if (pow > 0) { + for (int i = pow; i > 0; i--) { + result *= number; + } + } else if (pow < 0) { + for (int i = pow; i < 0; i++) { + result /= number; + } + } + return result; + } +}