CS 161 Assignment #6

Due Friday, March 8th by 11:59pm
(Not accepted after 3/17)

Introduction

Let's bounce some (more) boulders! NASA recently called and asked you to consult on their latest astronomical simulations. When they heard you'd worked with bouncing boulders on a lab exercise, they hired you on the spot. NASA wants to be able to create large collections of boulder-like objects and simulate their motions on the screen. They've got a few more requests that you can read about below.

The Assignment

We bounced some boulders back on lab #3, but now that we know about ArrayLists we can create and store lots of boulders. And now that we know how to write loops, we can use loops to process all of our boulders (update all of their positions, for example). This assignment will give you some practice with lists and loops, as well as more practice generating random numbers.

I've created a new project to get you started. Please download and modify BouncingBouldersAsmt. The project looks a lot like the finished product from the Boulders lab: There's a Canvas class that helps display our objects, a Boulder class (that's smart enough to wrap instances around at the edges of the screen), and a BouncingBoulders class that's mostly empty at this point. First you'll make a few small improvements to the Boulder class, then define methods in the BouncingBoulders class.

Now open the BouncingBoulders class and work through the following steps: Here are some sample interactions with the project:
> BouncingBoulders bb;
> bb = new BouncingBoulders(20, 12.7);
> bb.updateAll(10);
> bb.hideSmallBoulders(30);
> bb.printBoulders();
The simulation contains the following 20 boulders:
1: Boulder of size 50 is at 372.1875893819677, 133.87776166702926 with velocity 11.932056023677355, -10.554410451924971
2: Boulder of size 19 is at 433.82398487718194, 481.6550233232082 with velocity -6.080615674768774, 4.478703423386534
3: Boulder of size 25 is at 14.205130964340174, 393.97603145969526 with velocity 11.11050281871444, 7.603736784016846
4: Boulder of size 52 is at 620.951230348042, 323.61362827344834 with velocity 5.114525160868034, -4.187689679784777
5: Boulder of size 38 is at 768.4674629842491, 373.37094868583165 with velocity -1.8793981371839266, 2.323836781228364
6: Boulder of size 5 is at 106.94259393133359, 409.1286104889523 with velocity 8.541187451017588, -2.0980170740851207
7: Boulder of size 85 is at 559.8017179562688, 586.6516362879815 with velocity 3.2945829012953443, 9.293225362880605
8: Boulder of size 61 is at 73.67532737888092, 339.2820163629544 with velocity 2.9759777387407453, -1.0460581268287026
9: Boulder of size 72 is at 298.9813930724454, 56.310425271045304 with velocity -7.514211507103362, -6.184408602214812
10: Boulder of size 79 is at 259.367607069451, 118.06378240920512 with velocity -6.236904329580232, -8.086859198656914
11: Boulder of size 20 is at 210.4299455624453, 51.74854161385595 with velocity -11.979467778706224, -10.387300080994471
12: Boulder of size 87 is at 92.4472745844761, 266.8843323512295 with velocity 4.929968828747171, 0.37729816731534704
13: Boulder of size 87 is at 176.9020855021274, 443.40914283421677 with velocity 6.68723550255034, 0.6345696053823122
14: Boulder of size 59 is at 116.95477788856252, 578.302522353816 with velocity 11.197388847833434, 0.8888208572255731
15: Boulder of size 38 is at 182.33895355369228, 510.2331175188551 with velocity 4.35554045474316, 1.5838768509207295
16: Boulder of size 94 is at 764.2096929809328, 583.0330363997685 with velocity 0.4981611359740228, 6.4416864952641895
17: Boulder of size 25 is at 743.6657674362261, 486.7389217987581 with velocity 5.246475024380597, -5.967682834319399
18: Boulder of size 72 is at 242.15509909537224, 23.900988670872266 with velocity -7.936130021313706, -1.6208086389260128
19: Boulder of size 69 is at 577.4461866270992, 116.54887921309651 with velocity 12.44206759523237, 0.1350090685929981
20: Boulder of size 79 is at 234.82617887977983, 265.7267573132114 with velocity -11.455051901839385, 6.173991802852747

Comments

Each and every method should have a "javadoc-style" comment above it (the ones that use /** ... */). For full credit, you should use the @param and @return tags as appropriate in these method comments. Each instance variable should have a brief comment as well, and you should look for opportunities to use constants to tidy up your code. Don't forget the main comment at the top of the class either — I'm looking for more than just a sentence or two.

Grading

This assignment will be graded out of a total of 100 points:

Extending the Assignment

If you're looking for extra challenges, consider the following:

Submitting

Before submitting, make sure you've added your name to the comment at the top of the class file, and written comments for each method. Test your methods thoroughly. When you're convinced that it's ready to go, submit the assignment using BlueJ's submission tool as described here.


Brad Richards, 2024