Homework 02

Due: 2016-09-29T23:59:59

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 ramped up on Classes and Data Abstraction. This project will:

Problem Description

For the last assignment we had you implement a (what should have been) very straightforward and basic version of Civilization. Like many of you noted on Piazza that implementation was so basic it just barely followed the actual game design! Well keep in mind we are working on an iterative process of creating this big project, and the next step is to get some more features of the game set up. You will be creating classes to represent Civilizations, Resources, Victories, and Different types of Terrain.

Before we begin…

Solution Description

Resources

You will be writing 2 resource classes: Treasury.java and Game.java, Two additional resource classes, CoalMine.java and Fish.java, have already been written for you. Take a look at their descriptions to get ideas of how to complete the other resources.

Treasury.java:

This is one of the most important classes in the game. Almost any action that your civilization takes will require using their Treasury.

Game.java

Wild game objects will provide food for your citizens!

Fish.java

Fish will provide food for your citizens! This class is also already provided for you. You do not need to change anything about the provided file. We provide it’s description below.

CoalMine.java

Victories

In Civilization there are many different ways to achieve “victory” or win the game. We will focus on just 2:

Technology.java

You will be writing a technology class that represents how advanced the civilization is. There will be some boolean values that will be used to determine if the player has won the game. Throughout the game, players will perform actions that allow them to improve their technology. Once their technology has reached a certain state, they will have won the game.

Strategy.java

The strategy class has to do with war strategy.

If conqueredTheWorld gets set to true, then victory has been achieved!

Terrains

Your Civilization will have 3 Terrains: Desert.java, Hills.java, River.java. Terrains provide you with food and treasure.

River.java

Hills.java

Hills.java has been provided for you. We provide its description below, but you do not need to make any changes to this class.

The Hills terrain allows your citizens to gain 3 resources: Game, Gold, and Coal.

Desert.java

The primary function of a Desert is to find treasure of course! Some of Desert.java has been implemented for you. You will not need to add anything to the lost method.

Population.java

This class represents the population of a certain civilization as a whole.

Settlements

Below describes the classes involved in settling new cities.

Building.java

This class is also already provided for you. You do not need to change anything about the provided file. We provide it’s description below.

A Building object is the most basic element of a civilization. A building should have an integer cost and an integer workersRequired. A Building should have a constructor that takes in cost and workersRequired parameters and assigns them to each corresponding piece of instance data.

Settlement.java

A Settlement object is composed of Building objects. Your Settlement object MUST have an array of Building objects, as well as a String name. Settlement will have the following methods:

Civilizations

You will be writing 3 civilization classes: Egypt.java, RomanEmpire.java, and QinDynasty.java

Egypt.java

QinDynasty.java

RomanEmpire.java

As you work…

Any time you get some code written and running you should push your changes up to the remote repository:

  1. Type git status to see what changes are staged or unstaged
  2. Type git add * to add all changes you have made to be staged for commit
  3. Type git commit -m "My message" to commit your changes to your local repository.
  4. Type git pull origin master to make sure you are up-to-date with the remote version of the repository.
  5. Type git push origin master to push your changes up to the remote repository.

Tips, Tricks, and Reminders

Checkstyle

Peruse the CS1331 style guide here. This also has the instructions for how to run checkstyle on your code. Here’s a more step-by-step rundown:

What gets printed out is the list of all style errors your code has. Do your best to fix all of them and start coding in the correct style. Each individual checkstyle error results in -1 points on your assignment.

Maximum number of points you can lose on Checkstyle this assignment: 20

Turn-in Procedure

In order to submit your assignment you need to ensure that your working code is pushed to your remote repository by the due date! Follow the instructions outlined above to push your code to your remote repository!

You should have the following in your repository:

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!