Part of Slepp's ProjectsPastebinTURLImagebinFilebin
Feedback -- English French German Japanese
Create Upload Newest Tools Donate
Sign In | Create Account

javacity
Tuesday, October 14th, 2008 at 5:34:31pm MDT 

  1. import java.util.Scanner;
  2. public class JavaCity
  3. {       
  4.         private String JavaCity;
  5.  
  6.         public void setJavaCity(String Name) {
  7.                 JavaCity = Name ;}
  8.  
  9.         public String getJavaCity() {
  10.                 return JavaCity;}
  11.  
  12.         public void displayMessage(){
  13.                 System.out.println("Welcome to my City!");
  14.         }
  15.         private int Round=1;
  16.         private int Population=0;
  17.         private int Culture=0;
  18.         private int Food=0;
  19.         private int Productivity=0;
  20.         private int Wealth=0;
  21.         private int choice;
  22.  
  23.         public void printStat(){
  24.                 do {
  25.                
  26.                         System.out.println();
  27.                 System.out.printf("Round %d,[Population: %d,Culture: %d,Food: %d,Productivity: %d,Wealth: %d]\n",Round,Population,Culture,Food,Productivity,Wealth);
  28.                 System.out.printf("Please select:\n1.Add Professional\n2.Add Farmer\n3.Add Worker\n4.Add Businessman\n5.Leave the city");
  29.                 Round += 1;
  30.  
  31.                 Scanner gh = new Scanner(System.in);
  32.                 System.out.println();
  33.                 System.out.print("Your choice --> ");   
  34.                 choice = gh.nextInt();//public void askForInput()
  35.                
  36.                         if (choice == 1){
  37.                 Population += 1000;
  38.                 Culture += 1;
  39.                 Food -= 1;
  40.                 Productivity -= 1;
  41.                 System.out.print("Message: adding 1000 Professional to the city!\n");//public void addProfessional()
  42.                         }
  43.                
  44.                 else    if (choice == 2){
  45.                 Population += 1000;
  46.                 Food += 1;
  47.                 System.out.print("Message: adding 1000 Farmer to the city!\n")
  48.                 }//     public void addFarmer()
  49.  
  50.                 else if (choice == 3){
  51.                         Population += 1000;
  52.                         Food -= 1;
  53.                         Productivity += 1;
  54.                         System.out.print("Message: adding 1000 Worker to the city!\n");
  55.                 }//public void addWorker()
  56.                
  57.                  else if (choice == 4){
  58.                         Population += 1000;
  59.                         Food -= 2;
  60.                         Productivity += 1;
  61.                         Wealth += 1;
  62.                         System.out.print("Message: adding 1000 Businessman to the city!\n");//public void addBusinessman()
  63.                  }      
  64.                  else if (choice == 5){
  65.                  System.out.print("Bye!\n");}
  66.                         else if(choice >= 6){
  67.                         System.out.print("!!! Wrong input. Please try again. !!!\n");}
  68.         }while((choice != 5 )&&(choice <=5));
  69.         }
  70.  
  71. public static void main(String args[]){
  72.  
  73.         JavaCity  nj = new JavaCity();
  74.         nj.displayMessage();
  75.         nj.printStat();
  76.  
  77. }
  78. }

advertising

Update the Post

Either update this post and resubmit it with changes, or make a new post.

You may also comment on this post.

update paste below
details of the post (optional)

Note: Only the paste content is required, though the following information can be useful to others.

Save name / title?

(space separated, optional)



Please note that information posted here will expire by default in one month. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.

fantasy-obligation