serhatyucell

dfdfdfdf

Nov 30th, 2016
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 13.20 KB | None | 0 0
  1. import java.util.ArrayList;
  2. import java.util.Random;
  3. import java.util.Scanner;
  4.  
  5. public class CSGO {
  6.  
  7.     public static void main(String[] args) {
  8.         //Anahtar Sistemi
  9.         int totalCash = 100;
  10.         int currentCash = 100;
  11.         int kroma3KeyPrice = 7;
  12.         int kroma2KeyPrice = 5;
  13.         int ankaKeyPrice = 3;
  14.         int revolverKeyPrice = 4;
  15.         int kroma3keybought = 0, kroma2keybought = 0, ankakeybought = 0, revolverkeybought = 0;
  16.        
  17.         boolean turnHead = false;
  18.         boolean finall = false;
  19.         boolean returnStart = false;
  20.        
  21.        
  22.         while (finall == false) {
  23.         System.out.println("---[<<CASH INFO>>]---");
  24.         System.out.println("Info: You have " + currentCash + "$ in your wallet. \n");
  25.        
  26.         System.out.println("---[<<KEYS>>]---\nYou have Kroma 3 Key: " + kroma3keybought + "\nYou have Kroma 2 Key: " + kroma2keybought + "\nYou have Anka Key: " + ankakeybought + "\nYou have Revolver Key: " + revolverkeybought);
  27.         System.out.println("\n---[<<WEAPONS>>]---");
  28.         weaponList();
  29.        
  30.        
  31.         System.out.println("\n---[<<START PAGE MENU>>]---");
  32.         System.out.println("1: To Buy Case Key\n2: To Open Case\n3: To sell weapon\nEnter your choice:");
  33.         Scanner mainmenu = new Scanner (System.in);
  34.         int menu = mainmenu.nextInt();
  35.        
  36.         if (menu==1) {
  37.            
  38.             //Credit System is Starting
  39.            
  40.            
  41.            
  42.             while (turnHead == false && currentCash >= kroma3KeyPrice || currentCash >= kroma2KeyPrice || currentCash >= ankaKeyPrice || currentCash >= revolverKeyPrice) {
  43.            
  44.             System.out.println("\n--[KEY MENU]--\nWhich type key do you want to buy? \n1:Kroma 3 Key (" + kroma3KeyPrice + "$)\n2:Kroma 2 Key (" + kroma2KeyPrice + "$)\n3:Anka Key (" + ankaKeyPrice + "$)\n4:Revolver Key (" + revolverKeyPrice + "$)\n5:Return Start Menu");
  45.             System.out.print("Enter the type value: ");
  46.             Scanner type = new Scanner (System.in);
  47.             int keyType = type.nextInt();          
  48.            
  49.             if (keyType!=5) {
  50.                
  51.                
  52.                
  53.                 while (returnStart = false && currentCash >= kroma3KeyPrice || currentCash >= kroma2KeyPrice || currentCash >= ankaKeyPrice || currentCash >= revolverKeyPrice) {
  54.                    
  55.                     if (keyType == 1) {
  56.                         Scanner keyNumberBuy = new Scanner (System.in);
  57.                         System.out.print("How much key do you want? Max(" + maxKeyNumber(currentCash, kroma3KeyPrice) + ") | 0: Change Key Type : ");
  58.                         int keyNumber = keyNumberBuy.nextInt();
  59.                         int boughtKeyPrice = keyNumber*kroma3KeyPrice;
  60.                         int newCurrentCash = (currentCash)-(keyNumber*kroma3KeyPrice);
  61.                        
  62.                         if (keyNumber==0) {
  63.                             System.out.println("--Logged Out!\n");
  64.                             break;
  65.                         }
  66.                        
  67.                         else if (newCurrentCash >= 0 && keyNumber <= maxKeyNumber(currentCash, kroma3KeyPrice)) {
  68.                             System.out.println("+Succes: You bought " + keyNumber + " Kroma3 key and " + newCurrentCash + "$ cash left.");
  69.                             currentCash = newCurrentCash;
  70.                             kroma3keybought = kroma3keybought +keyNumber;
  71.                            
  72.                         }
  73.                        
  74.                         else {
  75.                             System.out.println("You can not buy more than max key value! Your cash is not enough!");
  76.                         }
  77.                        
  78.                        
  79.                     }
  80.                    
  81.                     else if (keyType == 2) {
  82.                         Scanner keyNumberBuy = new Scanner (System.in);
  83.                         System.out.print("How much key do you want? Max(" + maxKeyNumber(currentCash, kroma2KeyPrice) + ") | 0: Change Key Type : ");
  84.                         int keyNumber = keyNumberBuy.nextInt();
  85.                         int boughtKeyPrice = keyNumber*kroma2KeyPrice;
  86.                         int newCurrentCash = (currentCash)-(keyNumber*kroma2KeyPrice);
  87.                        
  88.                         if (keyNumber==0) {
  89.                             System.out.println("--Logged Out!\n");
  90.                             break;
  91.                         }
  92.                        
  93.                         if (newCurrentCash >= 0 && keyNumber <= maxKeyNumber(currentCash, kroma2KeyPrice)) {
  94.                             System.out.println("+Succes: You bought " + keyNumber + " Kroma2 key and " + newCurrentCash + "$ cash left.");
  95.                             currentCash = newCurrentCash;
  96.                             kroma2keybought = kroma2keybought +keyNumber;
  97.                         }
  98.                        
  99.                         else {
  100.                             System.out.println("You can not buy more than max key value! Your cash is not enough!");
  101.                         }
  102.                        
  103.                     }
  104.                    
  105.                     else if (keyType == 3) {
  106.                         Scanner keyNumberBuy = new Scanner (System.in);
  107.                         System.out.print("How much key do you want? Max(" + maxKeyNumber(currentCash, ankaKeyPrice) + ") | 0: Change Key Type : ");
  108.                         int keyNumber = keyNumberBuy.nextInt();
  109.                         int boughtKeyPrice = keyNumber*ankaKeyPrice;
  110.                         int newCurrentCash = (currentCash)-(keyNumber*ankaKeyPrice);
  111.                        
  112.                         if (keyNumber==0) {
  113.                             System.out.println("--Logged Out!\n");
  114.                             break;
  115.                         }
  116.                        
  117.                         if (newCurrentCash >= 0 && keyNumber <= maxKeyNumber(currentCash, ankaKeyPrice)) {
  118.                             System.out.println("+Succes: You bought " + keyNumber + " Anka key and " + newCurrentCash + "$ cash left.");
  119.                             currentCash = newCurrentCash;
  120.                             ankakeybought = ankakeybought +keyNumber;
  121.                         }
  122.                        
  123.                         else {
  124.                             System.out.println("You can not buy more than max key value! Your cash is not enough!");
  125.                         }
  126.                        
  127.                     }
  128.                    
  129.                     else if (keyType == 4) {
  130.                         Scanner keyNumberBuy = new Scanner (System.in);
  131.                         System.out.print("How much key do you want? Max(" + maxKeyNumber(currentCash, revolverKeyPrice) + ") | 0: Change Key Type : ");
  132.                         int keyNumber = keyNumberBuy.nextInt();
  133.                         int boughtKeyPrice = keyNumber*revolverKeyPrice;
  134.                         int newCurrentCash = (currentCash)-(keyNumber*revolverKeyPrice);
  135.                        
  136.                         if (keyNumber==0) {
  137.                             System.out.println("--Logged Out!\n");
  138.                             break;
  139.                         }
  140.                        
  141.                         if (newCurrentCash >= 0 && keyNumber <= maxKeyNumber(currentCash, revolverKeyPrice)) {
  142.                             System.out.println("+Succes: You bought " + keyNumber + " Revolver key and " + newCurrentCash + "$ cash left.");
  143.                             currentCash = newCurrentCash;
  144.                             revolverkeybought = revolverkeybought +keyNumber;
  145.                         }
  146.                        
  147.                         else {
  148.                             System.out.println("You can not buy more than max key value! Your cash is not enough!");
  149.                         }
  150.                     }
  151.                    
  152.  
  153.                    
  154.                     else {
  155.                         System.out.println("Please enter valid key type number!\n");
  156.                         break;
  157.                     }
  158.                    
  159.                    
  160.                     }//while    
  161.                
  162.                
  163.                
  164.                
  165.             }
  166.            
  167.            
  168.             else {
  169.                 System.out.println("\n+Succes: You returned to start menu!\n");
  170.                 break;
  171.             }
  172.  
  173.             }//while
  174.            
  175.            
  176.            
  177.             //Credits System Ending Here!          
  178.            
  179.         }
  180.        
  181.         else if (menu==2) {
  182.            
  183.             //Kasa Açma Bölümü Burada Başlıyor
  184.            
  185.                // Kroma 3 Kasası Şans Değerleri
  186.             String[] kroma3 = new String[100];
  187.             String[] kroma2 = new String[100];
  188.             String[] anka = new String[100];
  189.             String[] revolver = new String[100];
  190.             //%50
  191.             for (int i = 0; i < 50; i++) {
  192.                 kroma3[i] = "Kroma 3 >> Iron Weapon";
  193.                 kroma2[i] = "Kroma 2 >> Iron Weapon";
  194.                 anka[i] = "Anka >> Iron Weapon";
  195.                 revolver[i] = "Revolver >> Iron Weapon";
  196.                
  197.             }
  198.             //%25
  199.             for (int i = 50; i < 75; i++) {
  200.                 kroma3[i] = "Kroma 3 >> Silver Weapon";
  201.                 kroma2[i] = "Kroma 2 >> Silver Weapon";
  202.                 anka[i] = "Anka >> Silver Weapon";
  203.                 revolver[i] = "Revolver >> Silver Weapon";
  204.                
  205.             }
  206.             //%20
  207.             for (int i = 75; i < 95; i++) {
  208.                 kroma3[i] = "Kroma 3 >> Gold Weapon";
  209.                 kroma2[i] = "Kroma 2 >> Gold Weapon";
  210.                 anka[i] = "Anka >> Gold Weapon";
  211.                 revolver[i] = "Revolver >> Gold Weapon";
  212.                
  213.             }
  214.             //%5
  215.             for (int i = 95; i <= 99; i++) {
  216.                 kroma3[i] = "Kroma 3 >> Titanium Weapon";
  217.                 kroma2[i] = "Kroma 2 >> Titanium Weapon";
  218.                 anka[i] = "Anka >> Titanium Weapon";
  219.                 revolver[i] = "Revolver >> Titanium Weapon";
  220.                
  221.             }
  222.            
  223.             // Silahların Kalitesi
  224.            
  225.             String[] weaponQuality = new String[100];
  226.             //%30
  227.             for (int i = 0; i < 30; i++) {
  228.                 weaponQuality[i] = " | Industrial Grade";
  229.                
  230.             }
  231.             //%30
  232.             for (int i = 30; i < 60; i++) {
  233.                 weaponQuality[i] = " | Restricted";
  234.                
  235.             }
  236.             //%25
  237.             for (int i = 60; i < 85; i++) {
  238.                 weaponQuality[i] = " | Classified";
  239.                
  240.             }
  241.             //%15
  242.             for (int i = 85; i < 99; i++) {
  243.                 weaponQuality[i] = " | Special Edition";
  244.                
  245.             }
  246.            
  247.             if (kroma3keybought>0 || kroma2keybought>0 || ankakeybought>0 || revolverkeybought>0) {
  248.                
  249.                
  250.                  System.out.println("\n1-Kroma 3 | 2-Kroma 2 | 3-Anka Operasyon | 4-Revolver Case | 5-Exit");
  251.                    
  252.                     boolean finish = false;
  253.                    
  254.                     while(finish==false) {
  255.                  
  256.                        
  257.                     Scanner s = new Scanner (System.in);    
  258.                     System.out.print("\nSelect the box which you want to open: ");
  259.                     int kutu = s.nextInt();
  260.                        
  261.                     Random w = new Random();
  262.                     int RandomWeapon = w.nextInt(100);
  263.                     Random q = new Random();
  264.                     int RandomWeaponQuality = q.nextInt(100);
  265.                  
  266.          
  267.                    if (kutu==1) {
  268.                        
  269.                        if (kroma3keybought>0) { //kroma3 anahtarı var mı kontrol et
  270.                            System.out.println("\n+You won new weapon: " + kroma3[RandomWeapon] + weaponQuality[RandomWeaponQuality]);
  271.                            guns.add(kroma3[RandomWeapon] + weaponQuality[RandomWeaponQuality]);
  272.                            kroma3keybought--;
  273.                         }
  274.                        
  275.                        else {
  276.                            System.out.println("\n-Fail: You do not have Kroma 3 Key!");
  277.                        }
  278.                        
  279.                        
  280.                     }
  281.                    
  282.                     else if (kutu==2) {
  283.                        
  284.                            if (kroma2keybought>0) { //kroma2 anahtarı var mı kontrol et
  285.                                System.out.println("\n+You won new weapon: " + kroma2[RandomWeapon] + weaponQuality[RandomWeaponQuality]);
  286.                                guns.add(kroma2[RandomWeapon] + weaponQuality[RandomWeaponQuality]);
  287.                                kroma2keybought--;
  288.                             }
  289.                            
  290.                            else {
  291.                                System.out.println("\n-Fail: You do not have Kroma 2 Key!");
  292.                            }
  293.                        
  294.                     }
  295.                    
  296.                     else if (kutu==3) {
  297.                        
  298.                            if (ankakeybought>0) { //anka anahtarı var mı kontrol et
  299.                                System.out.println("\n+You won new weapon: " + anka[RandomWeapon] + weaponQuality[RandomWeaponQuality]);
  300.                                guns.add(anka[RandomWeapon] + weaponQuality[RandomWeaponQuality]);
  301.                                ankakeybought--;
  302.                             }
  303.                            
  304.                            else {
  305.                                System.out.println("\n-Fail: You do not have Anka Key!");
  306.                            }
  307.                        
  308.                     }
  309.                    
  310.                     else if (kutu==4) {
  311.                            if (revolverkeybought>0) { //revolver anahtarı var mı kontrol et
  312.                                System.out.println("\n+You won new weapon: " + revolver[RandomWeapon] + weaponQuality[RandomWeaponQuality]);
  313.                                guns.add(revolver[RandomWeapon] + weaponQuality[RandomWeaponQuality]);
  314.                                revolverkeybought--;
  315.                             }
  316.                            
  317.                            else {
  318.                                System.out.println("\n-Fail: You do not have Revolver Key!");
  319.                            }
  320.                     }
  321.                    
  322.                     else if (kutu==5) {
  323.                        
  324.                         Scanner exit = new Scanner (System.in);
  325.                         System.out.println("Are you sure about the exit? [y,n]:");
  326.                         char exit2 = exit.nextLine().charAt(0);
  327.                         if (exit2 == 'y' || exit2 == 'Y' ) {
  328.                             break;
  329.                         }
  330.                        
  331.                         else {
  332.                             continue;
  333.          
  334.                         }
  335.                     }
  336.                    
  337.                     else if (kutu>=6) {
  338.                         System.out.println("Please choose correct case number!");
  339.                     }
  340.                    
  341.                    
  342.                    
  343.                     }
  344.                    
  345.                
  346.                
  347.                   //Kasa Açma Bölümü Burada Bitiyor
  348.                
  349.                
  350.             } //if bitti - kasa anahtarı varsa
  351.            
  352.                
  353.             else { //hiç kasa anahtarı yoksa
  354.                 System.out.println("-Fail: You don't have any key! Firstly, you have to buy key.\n");
  355.             }
  356.                
  357.            
  358.            
  359.         }
  360.         // silah satma fonksiyonu başlıyor
  361.        
  362.         else if (menu==3) {
  363.            
  364.            
  365.             boolean sellgun = false;
  366.            
  367.             while(sellgun == false) {
  368.            
  369.             Scanner sg = new Scanner (System.in);
  370.             System.out.println("Plaese enter the weapon ID to sell: ");
  371.             int sgchoice = sg.nextInt();
  372.            
  373.             if (sgchoice != 0) {
  374.             guns.remove(sgchoice-1);
  375.             }
  376.            
  377.             else {
  378.                 break;
  379.             }
  380.            
  381.         }// sellgun while
  382.            
  383.         }//menu 3 bitti
  384.        
  385.         else  { //start menude 1,2 veya 3 dışında bir şeye basıldıysa
  386.             System.out.println("Please enter valid menu option!");
  387.         }
  388.        
  389.        
  390.        
  391.  
  392.     }//first while
  393.    
  394.    
  395.    
  396.    
  397.     }//main methods ending
  398.  
  399.     private static void weaponList(ArrayList<String> guns) {
  400.         ArrayList<String> guns = new ArrayList<String>();
  401.         int size = guns.size();
  402.         if (size == 0){
  403.             System.out.println("You don't have any weapon");
  404.         }
  405.        
  406.         else {
  407.             for (int i = 0; i < size; i++) {
  408.                 Object allweapons = guns.get(i);
  409.                 System.out.println((i+1) + ": " + allweapons);
  410.             }
  411.         }
  412.     }
  413.    
  414.  
  415.     private static int maxKeyNumber(int currentCash, int x) {
  416.         int maxKeyNumber = currentCash/x;
  417.         return maxKeyNumber;
  418.        
  419.     }
  420.    
  421.  
  422.  
  423. }
Advertisement
Add Comment
Please, Sign In to add comment