Konix

Influence Calculator 2

Dec 3rd, 2013
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 6.92 KB | None | 0 0
  1. /**
  2. A program that allows NationStates players to calculate
  3. their regional influence levels in the future using
  4. current data. Some goodies for the raiders included ;)
  5.  
  6. @auth Ambroscus Koth
  7. @vers 2.0
  8. @date 12/03/13
  9. */
  10.  
  11. import java.util.ArrayList;
  12. import java.util.Scanner;
  13.  
  14. public class InfCalc2
  15. {
  16.    private String name;
  17.    private int endos;
  18.    private int updates;
  19.    private int currentSPDR;
  20.    private double SPDRatDate;
  21.    private int lowerRI;
  22.    private int higherRI;
  23.    private double lowerRIatDate;
  24.    private double higherRIatDate;
  25.    private int lowerBR;
  26.    private int higherBR;
  27.    private double lowerBRatDate;
  28.    private double higherBRatDate;
  29.    private int caster1;
  30.    private int caster2;
  31.    private int caster3;
  32.    private int caster4;
  33.    private int caster5;
  34.    
  35.    public InfCalc2(String name, int currentSPDR, int endos, int updates)
  36.    {
  37.       this.name = name;
  38.       this.currentSPDR = currentSPDR;
  39.       this.endos = endos;
  40.       this.updates = updates;
  41.      
  42.       SPDRatDate = Math.sqrt(((endos +1) * updates) + (currentSPDR * currentSPDR));
  43.       caster1 = (int)SPDRatDate;
  44.      
  45.       lowerRI = (currentSPDR * currentSPDR);
  46.       higherRI = (((currentSPDR + 1) * (currentSPDR + 1)) - 1);
  47.      
  48.       lowerRIatDate = (SPDRatDate * SPDRatDate);
  49.       higherRIatDate = (((SPDRatDate + 1) * (SPDRatDate + 1)) - 1);
  50.       caster2 = (int)lowerRIatDate;
  51.       caster3 = (int)higherRIatDate;
  52.      
  53.       lowerBR = lowerRI * 2;
  54.       higherBR = higherRI * 2;
  55.      
  56.       lowerBRatDate = lowerRIatDate * 2;
  57.       higherBRatDate = higherRIatDate * 2;
  58.       caster4 = (int)lowerBRatDate;
  59.       caster5 = (int)higherBRatDate;
  60.    }
  61.    
  62.    public String getName()
  63.    {
  64.       return name;
  65.    }
  66.    
  67.    public int getSPDR()
  68.    {
  69.       return caster1;
  70.    }
  71.    
  72.    public int getLowerRI()
  73.    {
  74.       return lowerRI;
  75.    }
  76.    
  77.    public int getHigherRI()
  78.    {
  79.       return higherRI;
  80.    }
  81.    
  82.    public int getLowerRIatDate()
  83.    {
  84.       return caster2;
  85.    }
  86.    
  87.    public int getHigherRIatDate()
  88.    {
  89.       return caster3;
  90.    }
  91.    
  92.    public int getLowerBR()
  93.    {
  94.       return lowerBR;
  95.    }
  96.    
  97.    public int getHigherBR()
  98.    {
  99.       return higherBR;
  100.    }
  101.    
  102.    public int getLowerBRatDate()
  103.    {
  104.       return caster4;
  105.    }
  106.    
  107.    public int getHigherBRatDate()
  108.    {
  109.       return caster5;
  110.    }
  111.    
  112.    public static void main(String args[])
  113.    {
  114.       ArrayList<InfCalc2> victims = new ArrayList<InfCalc2>();
  115.      
  116.       char run = 'y';
  117.       while(run == 'y')
  118.       {
  119.          System.out.println("What do you want to do?");
  120.          System.out.println("   1. Just one nation calculation, please!");
  121.          System.out.println("   2. Invader Mode: Add many nations!");
  122.          System.out.println("   3. Invader Mode: Show me who I can banject!");
  123.          System.out.println("   4. Get me outta here!");
  124.          
  125.          Scanner scan = new Scanner(System.in);
  126.          int num = scan.nextInt();
  127.          
  128.          if(num > 4 || num < 0)
  129.          {
  130.             System.out.println("ERROR: You're retarded, please try again.");
  131.          }
  132.          
  133.          if(num == 1)
  134.          {
  135.             String name = null;
  136.            
  137.             System.out.println("Enter your current SPDR.");
  138.             int currentSPDR = scan.nextInt();
  139.      
  140.             System.out.println("Enter your current number of endorsements.");
  141.             int endos = scan.nextInt();
  142.      
  143.             System.out.println("Enter the number of updates.");
  144.             int updates = scan.nextInt();
  145.            
  146.             InfCalc2 result = new InfCalc2(name, currentSPDR, endos, updates);
  147.            
  148.             System.out.println("In " + result.updates + " updates, your SPDR will be at least " + result.getSPDR());
  149.             System.out.print("RI Range: ");
  150.             System.out.println( + result.getLowerRI() + " to " + result.getHigherRI());
  151.             System.out.print("Future RI Range: ");
  152.             System.out.println( + result.getLowerRIatDate() + " to " + result.getHigherRIatDate());
  153.             System.out.print("Banjection Range: ");
  154.             System.out.println( + result.getLowerBR() + " to " + result.getHigherBR());
  155.             System.out.print("Future Banjection Range: ");
  156.             System.out.println( + result.getLowerBRatDate() + " to " + result.getHigherBRatDate());
  157.            
  158.             Scanner input = new Scanner(System.in);
  159.             System.out.print("Would you like to do another calculation? ");
  160.             System.out.println("y/n");
  161.            
  162.             run = input.nextLine().charAt(0);
  163.          }//end case 1
  164.          
  165.          if(num == 2)
  166.          {
  167.             char moreNations = 'y';
  168.             while(moreNations == 'y')
  169.             {
  170.                System.out.println("Enter the nation name.");
  171.                String name = scan.next();
  172.                
  173.                System.out.println("Enter the nation's current SPDR.");
  174.                int currentSPDR = scan.nextInt();
  175.          
  176.                System.out.println("Enter the nation's current number of endorsements.");
  177.                int endos = scan.nextInt();
  178.          
  179.                System.out.println("Enter the number of updates.");
  180.                int updates = scan.nextInt();
  181.                
  182.                InfCalc2 result = new InfCalc2(name, currentSPDR, endos, updates);
  183.                victims.add(result);
  184.                
  185.                Scanner input = new Scanner(System.in);
  186.                System.out.print("Would you like to add another nation? ");
  187.                System.out.println("(y/n)");
  188.                
  189.                moreNations = input.nextLine().charAt(0);
  190.             }
  191.          }//end case 2
  192.          
  193.          if(num == 3)
  194.          {
  195.             for(int v = 0; v < victims.size(); v++)
  196.             {
  197.                InfCalc2 theDevoured = victims.get(v);
  198.                String victimName = theDevoured.getName();
  199.                int victimSPDR = theDevoured.getSPDR();
  200.                int victimLowerRIatDate = theDevoured.getLowerRIatDate();
  201.                int victimHigherRIatDate = theDevoured.getHigherRIatDate();
  202.                int victimLowerBRatDate = theDevoured.getLowerBRatDate();
  203.                int victimHigherBRatDate = theDevoured.getHigherBRatDate();
  204.                
  205.                System.out.println("Nation: " + victimName);
  206.                System.out.println("SPDR: " + victimSPDR);
  207.                System.out.println("Real Influence Range: " + victimLowerRIatDate + " to " + victimHigherRIatDate);
  208.                System.out.println("Banjection Range: " + victimLowerBRatDate + " to " + victimHigherBRatDate);
  209.                System.out.printf("\n===================== \n \n");
  210.             }
  211.          }//end case 3
  212.          
  213.          if(num == 4)
  214.          {
  215.             System.out.println("Whatever you say, kiddo.");
  216.             System.exit(1);
  217.          }//end case 3
  218.       }//end while loop "run"
  219.    }//end main
  220. }//end class
Advertisement
Add Comment
Please, Sign In to add comment