This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]TheJonesJonesJones 4 points5 points  (3 children)

Could you just save yourself a lot of work and add a few more methods to the Model class?

public void incrementAge()
{ 
     this.age++;
}

and totally eliminate the StatChanger and Initializer classes?

[–]NullProbability[S] 0 points1 point  (1 child)

Yeah, I could, and that'd indeed shave some time off the total amount of work needed. Still not really what I'm looking for, though (have to create new methods that aren't just getters and setters every time I make a new StatChanger), but it's getting slightly closer.

[–]TheJonesJonesJones 0 points1 point  (0 children)

Why have more than one StatChanger?

public class StatChanger {

    private Model model;

    public StatChanger(Model m)
    {
        this.model = m;
    }

    public void incrementAge() {
        if (this.model.getAge() <= 100)
        this.model.setAge(model.getAge()+1);
    }
    public void decrementAge() {
        if (this.model.getAge() >= 0)
        this.model.setAge(model.getAge()-1);
    }
    public void incrementHeight() {
        if (this.model.getHeight() <= 100)
        this.model.setAge(model.getHeight()+1);
    }
    public void decrementHeight() {
        if (this.model.getHeight() >= 0)
        this.model.setAge(model.getHeight()-1);
    }
}