Skip to content

Commit ad100b0

Browse files
authored
one believeth that he may eat all things
For one believeth that he may eat all things: but he that is weak, let him eat herbs (Romans 14:2)
1 parent 8140058 commit ad100b0

1 file changed

Lines changed: 82 additions & 0 deletions

File tree

‎task13/task1321/Solution.java‎

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
package com.javarush.task.task13.task1321;
2+
3+
//For one believeth that he may eat all things: but he that is weak, let him eat herbs (Romans 14:2)
4+
5+
/*
6+
Исправление ошибок
7+
*/
8+
9+
public class Solution {
10+
11+
public static void main(String[] args) throws Exception {
12+
System.out.println(Dream.HOBBIE.toString());
13+
System.out.println(new Hobbie().INDEX);
14+
}
15+
16+
interface Desire {
17+
}
18+
19+
interface Dream {
20+
public static Hobbie HOBBIE = new Hobbie();
21+
}
22+
23+
static class Hobbie implements Desire, Dream {
24+
static int INDEX = 1;
25+
26+
@Override
27+
public String toString() {
28+
INDEX++;
29+
return "" + INDEX;
30+
}
31+
}
32+
33+
}
34+
35+
36+
37+
38+
/*
39+
Исправление ошибок
40+
1. Переделай наследование в классах и интерфейсах так, чтобы программа компилировалась и продолжала делать то же самое.
41+
2. Класс Hobbie должен наследоваться от интерфейсов Desire, Dream.
42+
43+
44+
Требования:
45+
1. Интерфейс Desire должен быть реализован в классе Hobbie.
46+
2. Интерфейс Dream должен быть реализован в классе Hobbie.
47+
3. Класс Hobbie должен содержать статическую переменную INDEX.
48+
4. Метод toString в классе Hobbie должен инкрементировать и возвращать переменную INDEX в виде строки.
49+
50+
package com.javarush.task.task13.task1321;
51+
52+
53+
*
54+
Исправление ошибок
55+
*
56+
57+
public class Solution {
58+
59+
public static void main(String[] args) throws Exception {
60+
System.out.println(Dream.HOBBIE.toString());
61+
System.out.println(new Hobbie().INDEX);
62+
}
63+
64+
interface Desire {
65+
}
66+
67+
interface Dream implements Hobbie {
68+
public static Hobbie HOBBIE = new Hobbie();
69+
}
70+
71+
static class Hobbie extends Desire, Dream {
72+
static int INDEX = 1;
73+
74+
@Override
75+
public String toString() {
76+
INDEX++;
77+
return "" + INDEX;
78+
}
79+
}
80+
81+
}
82+
*/

0 commit comments

Comments
 (0)