Open limli opened 5 years ago
My guess would be that it looks something likes this:
I see. Thank you :)
@limli I'm not 100% sure though pls wait for profs reply
@daviddl9 I don't agree with your answer. Your sequence diagram suggests that the return statement occurs outside the if-else block.
So the code corresponding it would look something like
Task generate(boolean hasExisting) {
Task t;
if (hasExisting) {
t = getTask();
} else {
t = new Task();
}
return t;
}
(Sorry for poor indentation, I don't know how to use proper indentation in markdown)
I agree with @lingyanhao and I feel @limli 's diagram is more representative of the original algorithm...
Hi,
Indeed @limli's diagram is representative, while @daviddl9's diagram is incorrect when representing the return statements.
@limli's diagram: the return arrows need to be longer, and end outside the alt
box.
Best regards, Cristina
Okie thanks for the correction!
This is from sem 1's pyp. My question is, how do you represent a return statement inside of a if statement using sequence diagram? I believe "alt"s are used for if statements, but the return makes it a bit awkward.