view src/alice/test/dpp/codesegment/EatCodeSegment.java @ 14:33727db069c2

add ScheduleCodeSegment. modified CodeSegment
author one
date Wed, 28 Nov 2012 17:41:42 +0900
parents bfaaebb50a2e
children 7e91e919a7de
line wrap: on
line source

package alice.test.dpp.codesegment;

import alice.codesegment.CodeSegment;
import alice.datasegment.CommandType;
import alice.datasegment.Receiver;
import alice.test.dpp.model.Philosophy;

public class EatCodeSegment extends CodeSegment {

	Receiver arg1 = ids.create(CommandType.TAKE);
	
	public EatCodeSegment(String pName) {
		arg1.setKey(pName);
	}
	
	@Override
	public void run() {
		Philosophy phil = arg1.asClass(Philosophy.class);
		System.out.println(phil.getName() + " is eating.");
		phil.setState(Philosophy.State.PUTFORK);
		new ScheduleCodeSegment(phil.getName());
		ods.update("local", phil.getName(), phil);
	}
	
}