Formal Methods -- SE304/CS407 -- Lab 1
Design By Contract *is* useful
Thanks to
Gary Leavens
, who has made a lot of material on JML available on the web.
You need JML for this lab. It should already be installed, but if it's not,
it's available here.
Today's lecture on Design by Contract.
-
In teams, develop a class called Student and a class called Admin. The
student class should have two subject fields (these are double honours
students), a name field, a student number field, and the usual get and
set methods. The admin class should create several student objects and
print their contents to the screen.
-
The setSubject() method may cause problems, ie if it causes a student
to have the same subject in both subject fields. Use JML design by
contract to prevent this and similar problems.
-
Take note of any design decisions you make.
Developing Unit tests for your code can earn you extra marks which will be
added to your final mark. Here are some links you might find useful if you
decide to try it: