This repository was archived by the owner on Dec 10, 2021. It is now read-only.
File tree 4 files changed +78
-17
lines changed
4 files changed +78
-17
lines changed Original file line number Diff line number Diff line change
1
+ package ru .geekbrains ;
2
+
3
+ public abstract class Animal {
4
+ public abstract void speak ();
5
+ public abstract void run ();
6
+ public abstract void swim ();
7
+ String name ;
8
+ int run_dist ;
9
+ int swim_dist ;
10
+ public Animal (int run_dist ) {
11
+ this .run_dist = run_dist ;
12
+ }
13
+ public Animal (int swim_dist ) {
14
+ this .swim_dist = swim_dist ;
15
+ }
16
+ public Animal () {
17
+ name = "none" ;
18
+ }
19
+ public Animal (String name ) {
20
+ this .name = name ;
21
+ }
22
+ }
Original file line number Diff line number Diff line change 1
- package com . company ;
1
+ public class Cat extends Animal {
2
2
3
- public class Cat {
4
- String name ;
5
- int age ;
6
-
7
- public void sayMeow () {
8
- System .out .println (name + " meowed" );
9
- }
10
-
11
- public Cat (String name , int age ) {
12
- this .name = name ;
13
- this .age = age ;
14
- }
3
+ @ Override
4
+ public void speak () {
5
+ System .out .println ("Meow" );
6
+ }
7
+ public void run (run_length ) {
8
+ if (run_dist < 200 ) {
9
+ System .out .println (name + " has run " + run_dist + "meters" );
10
+ }
11
+ else {
12
+ break ;
13
+ }
14
+ }
15
+ public void swim () {
16
+ System .out .println ("Cats can't swim!" );
17
+ }
15
18
}
Original file line number Diff line number Diff line change
1
+ public class Dog extends Animal {
2
+
3
+ @ Override
4
+ public void speak () {
5
+ System .out .println ("Haw!" );
6
+ }
7
+ public void run (run_length ) {
8
+ if (run_dist < 500 ) {
9
+ System .out .println (name + " has run " + run_dist + "meters" );
10
+ }
11
+ else {
12
+ break ;
13
+ }
14
+ }
15
+ public void swim (swim_dist ) {
16
+ if (swim_dist < 10 ) {
17
+ System .out .println (name + " has swum " + swim_dist + "meters" );
18
+ }
19
+ else {
20
+ break ;
21
+ }
22
+ }
23
+ }
Original file line number Diff line number Diff line change @@ -262,13 +262,13 @@ public static void leap(int year) {
262
262
}*/
263
263
264
264
//lesson 6
265
- public class Main {
266
- /* public static void main(String args[]) {
265
+ /* public class Main {
266
+ public static void main(String args[]) {
267
267
Cat cat1 = new Cat("Oliver", 6);
268
268
Cat cat2 = new Cat("Pumpin", 5);
269
269
cat1.sayMeow();
270
270
cat2.sayMeow();
271
- }*/
271
+ }
272
272
273
273
public static void main(String args[]) {
274
274
Person[] persArray = new Person[5];
@@ -283,4 +283,17 @@ public static void main(String args[]) {
283
283
}
284
284
}
285
285
}
286
- }
286
+ }*/
287
+
288
+ //lesson 7
289
+ /*
290
+ public class Main {
291
+
292
+ public static void main(String[] args) {
293
+
294
+ Animal drujok = new Animal("Druzhok");
295
+ drujok.animalInfo();
296
+ drujok.jump();
297
+ Cat kitty = new Cat("Kitty", "white");
298
+ }
299
+ }*/
You can’t perform that action at this time.
0 commit comments