首页 > > 详细

You should start from the code

 You should start from the code published in the "assignments" branch of the workshops repository. We encourage you to make a fresh clone of this branch (in a separate folder on your computer) rather than trying to integrate it with your other work.

As part of the update, we've provided you with a library of additional classes in a jar file. Jar files are archives containing pre-compiled Java classes. The classpath has been updated so that you can access these classes.
The extra classes are as follows:
Camel - this is an additional sub-class of Actor.
Health - the overall status of the blue team is kept here, if it goes to zero the game is over and the red team has won. It has the following methods available:
 
public static void set(int v);    // will set the counter to the integer v
public static boolean depleted(); // true if the value of the counter has reached zero
public static void decrement();   // reduces the value in the counter by one
public static int get();          // returns the current value of the counter
The starting point for assignment three has a couple of problems:
The whole game randomly freezes sometimes whenever a Camel class decides to move.
The Health class is not thread safe.
Your job is to:
Make a change so that the game no longer randomly freezes whenever a Camel moves.
Write a demo class (with a main method) that will trigger and demonstrate the fact that Health class is not thread safe.
Adapt the Health class so  that it is thread safe for use in your code. Demonstrate that adapter (it may or may not actually be an adapter pattern, I am using the vernacular meaning of "adapter") is safe to use in the game.
 
Note:  Fixing the problem is very easy if you know where to look, thus we have allocated a significant proportion of the marks to your explanations.  Note also that you will need very clear and correct explanations for full marks.
Marking
 
联系我们
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 99515681 微信:codinghelp
程序辅导网!