Skip to content

Instantly share code, notes, and snippets.

@FagnerMartinsBrack
Created September 6, 2014 04:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FagnerMartinsBrack/69da19f8bb9c67828770 to your computer and use it in GitHub Desktop.
Save FagnerMartinsBrack/69da19f8bb9c67828770 to your computer and use it in GitHub Desktop.
import java.util.*;
import java.lang.*;
public class PersonExecutor {
public static void main( String[] arguments ){
Person john = new Person();
Person mike = new Person();
john.setName( "John" );
mike.setName( "Mike" );
Location location = new Location();
location.addPerson( john );
location.addPerson( mike );
System.out.print( location.toString() );
}
}
class Person {
private String name;
public void setName( String name ) {
this.name = name;
}
public String getName() {
return name;
}
}
class Location {
private List<Person> persons = new ArrayList<Person>();
public void addPerson( Person person ) {
persons.add( person );
}
@Override
public String toString() {
String result = "";
for ( Person person : persons ) {
result += person.getName() + " is here\n";
}
return result;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment