// File : hammurabi0/Hammurabi.java // Purpose: Starting point for working on the Hammurabi program. // Author : Fred Swartz // Source : www.roseindia.net/java/java-tips/oop/q-hammurabi/q-pr-hammurabi-1.shtml // License: MIT // Date : 07 Oct 2005 // TODO : * Prompt for amount to feed peasants. // * Check that there is enough grain to meet requests. // * Also stop simulation if population is 0 (while condition) public class hamurabi { //============================================================= main public static void main(String[] args) { //... Initialization kingdom sumer = new kingdom(); // Create a new Kingdom minister prime = new minister(); //... Run the simulation for 5 years or until everyone starves. while (sumer.getYear() <= 5) { //... Display state of the kingdom at beginning of each year. prime.tell(sumer.toString()); //TODO: Ask the ruler how much to feed the people. int food = 0; // Temporary substitute for asking for input. //.. Ask the ruler how much grain should be used for seed. int seeds = prime.ask("Exalted Ruler, how much of the remaining " + (sumer.getGrain()-food) + " bushels should be planted?"); //... TODO: Check if not enough grain for this request, Reprompt. //... Update the food and population of this kingdom. sumer.simulateOneYear(food, seeds); } //... Show final state. prime.tell("At end " + sumer.toString()); } }