Skip to content

Instantly share code, notes, and snippets.

@joakiti
Created September 13, 2016 10:22
Show Gist options
  • Save joakiti/a6f667853aa39ef57b12dde54f4ddad7 to your computer and use it in GitHub Desktop.
Save joakiti/a6f667853aa39ef57b12dde54f4ddad7 to your computer and use it in GitHub Desktop.
hejhejhejhej
import java.util.ArrayList;
public class BigForest {
private ArrayList<Tree> trees;
private int a;
public BigForest() // Opgave i
{
trees = new ArrayList<>();
}
// Opgave 2
public void show() {
for (Tree t : trees){
t.show();
}
}
public void GrowOneYear() {
for (Tree g : trees) {
g.GrowOneYear();
}
}
// Opgave 3
public void addFile(Tree t) {
trees.add(t);
}
public void growManyYears(int n) {
a = 0;
while ( a < n ) {
a++;
for (Tree t : trees) {
t.GrowOneYear();
new Tree(10.0);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment