-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
My zoo #1
base: master
Are you sure you want to change the base?
My zoo #1
Conversation
*/ | ||
public class App { | ||
public static void main(String[] args) { | ||
Zoo a1 = new Shark("Masanya_1"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Yura1977 називай змінні більш зрозуміло
array1.add(a2); | ||
array1.add(a3); | ||
array1.add(a4); | ||
ArrayList<Fish> array2 = new ArrayList<>();//Acvarium |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Yura1977 Я очікую що тут буде класс Cage з дженериками, WildCard і т.д
//Flyableable[] array2 = { s1,s2, b1, m1, p1, l1}; | ||
|
||
for (Zoo a : array1) { | ||
if (a instanceof Shark) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Yura1977 Це взагалі фігня)
for (Zoo a : array1) { | ||
if (a instanceof Shark) { | ||
Shark m = (Shark) a; | ||
System.out.println(m.name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Yura1977 p.name? А інкапсуляція? А Getters and Setters?
this.name = name; | ||
} | ||
|
||
abstract void eat(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Yura1977 В зоопарку є метод їсти??? Серйозно?
} | ||
} | ||
|
||
abstract class Mammal extends Zoo implements Flyableable { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Yura1977 Mammal це самець? Якщо так . - то він має має імплементити Flyableable?
void swimable(); | ||
} | ||
interface Flyableable{ | ||
default void flyable(){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Yura1977 А ти впевнений що цей метод має бути дефолтним?
System.out.println(name + "Sparrow fly very well"); | ||
} | ||
} | ||
class Pingvin extends Bird implements Swimable { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Yura1977 А що відбудеться коли викличемо метод fly() у пінгвіна?
Add changes. |
No description provided.