Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 10 additions & 0 deletions Cat.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
public class Cat extends Pet {

public Cat() {
}

@Override
public void voice(){
System.out.println("Я кіт- Мяууу-Мяууу");
};
}
10 changes: 10 additions & 0 deletions Cow.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
public class Cow extends Pet {

public Cow() {
}

@Override
public void voice(){
System.out.println("Я корова- Мууу-Мууу");
};
}
10 changes: 10 additions & 0 deletions Dog.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
public class Dog extends Pet {

public Dog() {
}

@Override
public void voice(){
System.out.println("Я пес- Гаууу-Гаууу");
};
}
49 changes: 49 additions & 0 deletions MyMath.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
public class MyMath {

private static final int ARG1 = 16;
private static final int ARG2 = 20;
private static final int ARG3 = -5;
private static final double ARG4 = 39.60;

static {
System.out.println("Параметри констант які були задані: ");
System.out.println("ARG1 -> " + ARG1);
System.out.println("ARG2 -> " + ARG2);
System.out.println("ARG3 -> " + ARG3);
System.out.println("ARG4 -> " + ARG4);
System.out.println();
}

public static int getARG1() {
return ARG1;
}

public static int getARG2() {
return ARG2;
}

public static int getARG3() {
return ARG3;
}

public static double getARG4() {
return ARG4;
}

public static int mathsumall(){
System.out.println("Вивести суму всіх значень -> " + (ARG1 + ARG2 + ARG3 + ARG4));
System.out.println();
return (int)(ARG1 + ARG2 + ARG3 + ARG4);
}

public static void mathround(){
System.out.println("Округлити значення із плаваючою комою -> " + getARG4() + " -> " + Math.round(getARG4()));
System.out.println();
}

public static void mathavg(){
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

camelcase

System.out.println("Визначити корінь кв. -> " + Math.sqrt(mathsumall()));
System.out.println();
}
}

17 changes: 17 additions & 0 deletions MyMathExecution.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import java.sql.SQLOutput;

public class MyMathExecution {
public static void main(String[] args) {
MyMath matemat = new MyMath();

int i;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

assign the result to this variable at once


matemat.mathsumall();
matemat.mathround();
matemat.mathavg();

i = Math.max(MyMath.getARG1(), MyMath.getARG2());

System.out.println("З елементів " + matemat.getARG1() + " та " + matemat.getARG2() + " більший: " + i);
}
}
7 changes: 7 additions & 0 deletions Pet.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
public abstract class Pet {

public Pet() {
}

public abstract void voice();
}
17 changes: 17 additions & 0 deletions PetExecution.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//Написати клас абстрактний Pet , в якому описати абстрактний метод voice(). Створити класи Cow, Cat, Dog , які наслідуються від Pet. Перевизначити в них метод voice(), так,
// щоб викликаючи його в методі main, на консоль виводилось : “Я кіт- Мяууу-Мяууу”, “Я пес- Гаууу-Гаууу”, “Я корова- Мууу-Мууу”.

public class PetExecution {
public static void main(String[] args) {

Pet dog = new Dog();
Pet cat = new Cat();
Pet cow = new Cow();
Dog dog1 = new Dog();

dog.voice();
dog1.voice();
cat.voice();
cow.voice();
}
}