Advanced Software Engineering
main() {
/* One student */
Student s(c1, c2, c3, c4):();
/* Four different courses. Each course
is initialised with the time it takes
to do this week's assignment */
Course c1(s):(10);
Course c2(s):(15);
Course c3(s):(4);
Course c4(s):(6);
}reactiveclass Student(30) {
knownrebecs {
/* Four courses */
}
statevars {
int energy;
boolean studying;
}
initial() {
/* Student has 16 hours in a day to study */
energy = 16;
studying = false;
}
msgsrv doAssignment(int time) {
/* Check if there is any energy left. If not
make the student go to sleep. Otherwise,
check if the student has enough energy.
Continue if this is true and hand in the
assignment. If not, work as much as
possible on the assignment and store the
rest for later. Make student go to sleep
and resume working on last assignment with
a new deadline. Finally, hand in the
assignment by calling the msgsrv receive
in Course. */
/* The student sleeps for 8 units of time
and resets the energy to 16 units of time */
}
}reactiveclass Course(30) {
knownrebecs {
/* One student */
}
statevars {
int deadline;
}
Course(int time) {
/* Assignments are published one week before deadline */
deadline = 120;
}
msgsrv publishAssigment(int time) {
/* Call doAssignment on Student with the deadline */
}
msgsrv receiveSolution(){
/* What now? How do we
know if the week is done? */
}
}