Last active
August 29, 2015 14:05
-
-
Save edysegura/370e99c3f946fc46bf10 to your computer and use it in GitHub Desktop.
Groovy learning - Todo Case
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 Todo { | |
def name | |
def note | |
public static void main(String[] args) { | |
def todos = [ | |
new Todo([name:'1', note:'One']), | |
new Todo([name:'2', note:'Two']), | |
new Todo([name:'3', note:'Three']), | |
new Todo([name:'4', note:'Four']) | |
] | |
todos.each { | |
println "${it.name} ${it.note}" | |
} | |
} | |
} |
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
import java.util.List; | |
import java.util.ArrayList; | |
public class Todo { | |
private String name; | |
private String note; | |
public Todo() {} | |
public Todo(String name, String note) { | |
this.name = name; | |
this.note = note; | |
} | |
public String getName() { | |
return name; | |
} | |
public void setName(String name) { | |
this.name = name; | |
} | |
public String getNote() { | |
return note; | |
} | |
public void setNote(String note) { | |
this.note = note; | |
} | |
public static void main(String[] args) { | |
List<Todo> todos = new ArrayList<Todo>(); | |
todos.add(new Todo("1", "One")); | |
todos.add(new Todo("2", "Two")); | |
todos.add(new Todo("3", "Three")); | |
todos.add(new Todo("4", "Four")); | |
for(Todo todo : todos) { | |
System.out.println(todo.getName() + " " + todo.getNote()); | |
} | |
} | |
} |
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 Todo { | |
def name | |
def note | |
} | |
def todos = [ | |
new Todo([name:'1', note:'One']), | |
new Todo([name:'2', note:'Two']), | |
new Todo([name:'3', note:'Three']), | |
new Todo([name:'4', note:'Four']) | |
] | |
todos.each { | |
println "${it.name} ${it.note}" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment