File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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+ */
You can’t perform that action at this time.
0 commit comments