Created
March 19, 2017 12:35
-
-
Save fermopili/bf6cd401418b7d94d9f50f3c350a4970 to your computer and use it in GitHub Desktop.
com.javarush.task.task13.task1327
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Person implements RepkaItem | |
{ | |
private String name; | |
private String namePadezh; | |
public Person(String name, String namePadezh) | |
{ | |
this.name = name; | |
this.namePadezh = namePadezh; | |
} | |
public String getName() | |
{ | |
return name; | |
} | |
public void pull(Person first) | |
{ | |
System.out.println( name+ " за " + first.namePadezh); | |
} | |
public void setName(String name) | |
{ | |
this.name = name; | |
} | |
public String getNamePadezh() | |
{ | |
return namePadezh; | |
} | |
public void setNamePadezh(String namePadezh) | |
{ | |
this.namePadezh = namePadezh; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Person implements RepkaItem | |
{ | |
private String name; | |
private String namePadezh; | |
public Person(String name, String namePadezh) | |
{ | |
this.name = name; | |
this.namePadezh = namePadezh; | |
} | |
public String getName() | |
{ | |
return name; | |
} | |
public void pull(Person first) | |
{ | |
System.out.println( name+ " за " + first.namePadezh); | |
} | |
public void setName(String name) | |
{ | |
this.name = name; | |
} | |
public String getNamePadezh() | |
{ | |
return namePadezh; | |
} | |
public void setNamePadezh(String namePadezh) | |
{ | |
this.namePadezh = namePadezh; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RepkaStory { | |
static void tell(List<Person> items) { | |
Person first; | |
Person second; | |
for (int i = items.size() - 1; i > 0; i--) { | |
first = items.get(i); | |
second = items.get(i-1); | |
first.pull(second); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Репка | |
*/ | |
public class Solution { | |
public static void main(String[] args) { | |
List<Person> plot = new ArrayList<Person>(); | |
plot.add(new Person("Репка", "Репку")); | |
plot.add(new Person("Дедка", "Дедку")); | |
plot.add(new Person("Бабка", "Бабку")); | |
plot.add(new Person("Внучка", "Внучку")); | |
RepkaStory.tell(plot); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment