Homework 04

Version: 1.6

Due: 2016-10-27T23:59:59

TODO

Download zip

Introduction

Civilization is a turn-based strategy game centered around founding and building a civilization. More commonly referred to as Sid Meier’s Civilization, the game has been around since 1991 and has since developed somewhat of a cult following. This semester we are going to be implementing our own version of this game for your homework assignments and by the end of the semester you will have a working game you can show off to your friends! If you are not familiar with Civilization, there is a free version that you can play in order to get familiar with the game.

This assignment will get you working with Collections and Exceptions. This project will:

Problem Description

You’ve now had some practice writing java Classes that use inheritance and polymorphism in a java program. It’s time to get a little more practical with our inheritance and polymorphism! We’ll do that by working with java Collections and java Exceptions.

Before we begin…

A little about Collections

“Collections” are 2 things:

In this assignment, you will in essence be implementing the Set class. A Set is a data structure that holds zero to infinity entries, holds only unique entries, and those entries have no ordering.

Compiling and Running

$ javac -cp src/main/java src/main/java/*/*.java
$ javac -cp src/main/java src/main/java/runner/*.java src/main/java/model/*.java src/main/java/view/*.java src/main/java/controller/*.java
$ java -cp src/main/java runner.CivilizationGame

Checkstyle

Solution Description

MySet.java

Your first custom java collection! This class will need to implement the provided SimpleSet interface and should be backed by an array. As you may have inferred, MySet is going to act like the abstract data type of a “set”. This means that it is going to not have any particular ordering, and it is only going to contain unique elements. Look at the javadocs for each method in the SimpleSet interface for details on how to implement this class!

NOTES:

FishingShack.java

If you recall, from HW03 the FishingShack class tracked several fish using an array. Well, you guys are clearly too advanced to be storing fish in arrays; so, we are going to store the Fish in our new MySet class! Implement the getFish() and replenishFish() methods in FishingShack.java. See the javadocs for those methods for implementation details.

Technology.java

Our Civilizations should also know what Technologies it has researched. We will call these “skills”. In the Technology class you are going to write the gainATech() method. See the javadocs for details.

Conclusion

Verifying Your Submission

Please be sure that any code you push compiles and runs through the command line! Pull from your repository and make sure everything is working how you want it!