Project 4, CSC 2001
1 Introduction
The last project! Whoa!
2 Learning Outcomes
At the end of this project, you should understand the correspondence between two different "refactored" versions of the same project. You should be able to extend code to add functionality, and you should be able to list some of the advantages and disadvantages of the different styles of code that you’ll see.
3 The project
So, here’s the idea. We’re giving you two versions of the project. They both do the same thing! Specifically, running them creates a small "virtual world", with entities that have their own roles and behaviors.
Ah, what the heck. Let’s go take a look at it. Here’s the link for the project 4 template:
https://github.com/cp-csc2001/csc2001-project4-template
Use this template to create your own repository.
Then, open the project in IntelliJ. You should see "Before" and "After" modules. Both of the modules contain a "VirtualWorld.java" file. Try running this file, in each version. You should see that they both behave the same. Well, up to the vagaries of random number generation, anyway.
Your job is to add something new! Here’s the catch: you need to add your thing to both versions of the code, the "Before" and the "After".
4 Before and After
What you’re seeing in the "Before" and "After" modules are the results of a refactoring; the intent of the refactoring is to increase "cohesion"—classes that express one idea clearly, where it’s obvious why these pieces belong together—and to decrease "coupling", where there is "tangling" between classes.
You should spend time reading the code. What does each method do? How did these coders get away without writing purpose statements for their methods? Someone needs a stern talking-to.
You might also want to try making small changes to the code. Can you make things move faster? Or slower? Or turn off their special abilities? Try to get a feel for how the code works.
One extremely valuable act would be to take a piece of paper, and sketch the classes of the project (more specifically, of each module) as a UML diagram. Let me strongly encourage you to use an actual physical writing implement; you might be surprised to discover the persistent effect on your memory of actually drawing the diagram with your hand.
5 Time for a Change: A world event!
Decide on a world-changing event (e.g., a river spawns, a volcano erupts, or a rainbow is cast across the land). This event must be triggered by a mouse-click and must affect at least 7 tiles of the world in proximity to the mouse position when the click occurs.if the user clicks within seven tiles of the world’s edge, this restriction does not apply. The event should affect no more than half of the world. Users can click the mouse as many times as they want.
The world event must be visualized by modifying the background image of the affected tiles. You are free to modify them however you would like, and you are encouraged to be creative.
6 A new entity
The world event must cause a new type of entity to spawn. This new entity should animate and move according to logic defined by you.
For instance, the new entity might seek out Fairy to turn them into something else, chase down Dude to infect them with the plague, or travel the world spreading some seeds.
7 Additional Requirements
The images for your changed background, affected entity, and new entity can be created by you or use online sources to find an entity. You may not use any of the existing images that came with the project. An exception is for your "affected entity", you may alter that entity’s current image.
Your changes must be done on both "Before" and "After" virtual world implementations. In your report you will be comparing these two implementations.
8 Summary Report
Include a PDF file named "ProjectReport.pdf" in your submission. It should contain no more than 1100 words.
First, describe your idea. What happens when you click? What entity is created? How does it look, and behave?
Next, describe the process of implementation. Which version did you decide to modify first? Were there problems that you ran into? Briefly summarize the changes you made to each project (two or three paragraphs per module is probably *plenty*).
Finally, describe what observations you have about the two projects, and what role the object-oriented design made. You’re welcome to highlight shortcomings of the OO design as well as advantages!
9 Submitting
This file contains a *lot* of source files. In order to make it possible to actually try out your code, it will be necessary to hand in in a format that preserves directory structure. To that end, you’ll need to either hand in using GitHub, *if that works for you*, or to submit a zip file.
As always, please make sure to ensure that your submission went through, and don’t forget to tag your partner, if you’re working as a team!