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
6 changes: 6 additions & 0 deletions Cat.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
public class Cat extends Pet {
@Override
void voice() {
System.out.println("Я кіт- Мяууу-Мяууу");
}
}
6 changes: 6 additions & 0 deletions Cow.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
public class Cow extends Pet {
@Override
void voice() {
System.out.println("Я корова- Мууу-Мууу");
}
}
6 changes: 6 additions & 0 deletions Dog.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
public class Dog extends Pet{
@Override
void voice() {
System.out.println("Я пес- Гаууу-Гаууу");
}
}
15 changes: 15 additions & 0 deletions Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
public class Main {
public static void main(String[] args) {
Pet cow = new Cow();
Pet cat = new Cat();
Pet dog = new Dog();
cow.voice();
cat.voice();
dog.voice();

System.out.println(MyMath.subtract(MyMath.Pi,MyMath.G));
System.out.println(MyMath.sum(MyMath.Pi,MyMath.G));
System.out.println(MyMath.multyply(MyMath.G));
System.out.println(MyMath.divide(MyMath.G));
}
}
21 changes: 21 additions & 0 deletions MyMath.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
public class MyMath {
public static final double Pi=3.14;
public static final double G=9.8;
public static final int TWO=2;

public static double subtract(double a, double b){
return a-b;
}

public static double sum(double a, double b){
return a+b;
}

public static double multyply(double a){
return a*TWO;
}

public static double divide(double a){
return a/TWO;
}
}
5 changes: 5 additions & 0 deletions Pet.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
abstract class Pet {

abstract void voice();

}