serhatyucell

CSGO[Selling Item]

Dec 1st, 2016
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 22.01 KB | None | 0 0
  1. import java.util.ArrayList;
  2. import java.util.Random;
  3. import java.util.Scanner;
  4.  
  5. public class CSGONew {
  6.  
  7.     public static void main(String[] args) {
  8.         //Para Sistemi
  9.         int totalCash = 100;
  10.         double currentCash = 100;
  11.         //Kasa anahtarı fiyatları
  12.         int kroma3KeyPrice = 7;
  13.         int kroma2KeyPrice = 5;
  14.         int ankaKeyPrice = 3;
  15.         int revolverKeyPrice = 4;
  16.         //Varsayılan satın alınmış kasa sayısı
  17.         int kroma3keybought = 0, kroma2keybought = 0, ankakeybought = 0, revolverkeybought = 0;
  18.        
  19.         //Döngüleri sonlandırmak için değişkenler
  20.         boolean turnHead = false;
  21.         boolean finall = false;
  22.         boolean returnStart = false;
  23.         //Silah envanteri için ArrayList
  24.         ArrayList<String> guns = new ArrayList<String>();
  25.         ArrayList<Double> gPrice = new ArrayList<Double>();
  26.        
  27.         //Program BAŞLIYOR...
  28.        
  29.         while (finall == false) {
  30.         System.out.println("---[<<CASH INFO>>]---");
  31.         System.out.println("Info: You have " + currentCash + "$ in your wallet. \n");
  32.        
  33.         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);
  34.         System.out.println("\n---[<<WEAPONS>>]---");
  35.         int size = guns.size();
  36.         printWeapons(size,guns,gPrice);
  37.        
  38.         System.out.println("\n---[<<START PAGE MENU>>]---");
  39.         System.out.println("1: To Buy Case Key\n2: To Open Case\n3: To sell weapon\nEnter your choice:");
  40.         Scanner mainmenu = new Scanner (System.in);
  41.         int menu = mainmenu.nextInt();
  42.        
  43.         if (menu==1) {
  44.            
  45.             //Credit System is Starting
  46.            
  47.            
  48.            
  49.             while (turnHead == false && currentCash >= kroma3KeyPrice || currentCash >= kroma2KeyPrice || currentCash >= ankaKeyPrice || currentCash >= revolverKeyPrice) {
  50.             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");
  51.             System.out.print("Enter the type value: ");
  52.             Scanner type = new Scanner (System.in);
  53.             int keyType = type.nextInt();          
  54.            
  55.             if (keyType!=5) {
  56.                
  57.                
  58.                
  59.                 while (returnStart = false && currentCash >= kroma3KeyPrice || currentCash >= kroma2KeyPrice || currentCash >= ankaKeyPrice || currentCash >= revolverKeyPrice) {
  60.                    
  61.                     if (keyType == 1) {
  62.                         Scanner keyNumberBuy = new Scanner (System.in);
  63.                         System.out.print("How much key do you want? Max(" + maxKeyNumber(currentCash, kroma3KeyPrice) + ") | 0: Change Key Type : ");
  64.                         int keyNumber = keyNumberBuy.nextInt();
  65.                         int boughtKeyPrice = keyNumber*kroma3KeyPrice;
  66.                         double newCurrentCash = (currentCash)-(keyNumber*kroma3KeyPrice);
  67.                        
  68.                         if (keyNumber==0) {
  69.                             System.out.println("--Logged Out!\n");
  70.                             break;
  71.                         }
  72.                        
  73.                         else if (newCurrentCash >= 0 && keyNumber <= maxKeyNumber(currentCash, kroma3KeyPrice)) {
  74.                             System.out.println("+Succes: You bought " + keyNumber + " Kroma3 key and " + newCurrentCash + "$ cash left.");
  75.                             currentCash = newCurrentCash;
  76.                             kroma3keybought = kroma3keybought +keyNumber;
  77.                            
  78.                         }
  79.                        
  80.                         else {
  81.                             System.out.println("You can not buy more than max key value! Your cash is not enough!");
  82.                         }
  83.                        
  84.                        
  85.                     }
  86.                    
  87.                     else if (keyType == 2) {
  88.                         Scanner keyNumberBuy = new Scanner (System.in);
  89.                         System.out.print("How much key do you want? Max(" + maxKeyNumber(currentCash, kroma2KeyPrice) + ") | 0: Change Key Type : ");
  90.                         int keyNumber = keyNumberBuy.nextInt();
  91.                         int boughtKeyPrice = keyNumber*kroma2KeyPrice;
  92.                         double newCurrentCash = (currentCash)-(keyNumber*kroma2KeyPrice);
  93.                        
  94.                         if (keyNumber==0) {
  95.                             System.out.println("--Logged Out!\n");
  96.                             break;
  97.                         }
  98.                        
  99.                         if (newCurrentCash >= 0 && keyNumber <= maxKeyNumber(currentCash, kroma2KeyPrice)) {
  100.                             System.out.println("+Succes: You bought " + keyNumber + " Kroma2 key and " + newCurrentCash + "$ cash left.");
  101.                             currentCash = newCurrentCash;
  102.                             kroma2keybought = kroma2keybought +keyNumber;
  103.                         }
  104.                        
  105.                         else {
  106.                             System.out.println("You can not buy more than max key value! Your cash is not enough!");
  107.                         }
  108.                        
  109.                     }
  110.                    
  111.                     else if (keyType == 3) {
  112.                         Scanner keyNumberBuy = new Scanner (System.in);
  113.                         System.out.print("How much key do you want? Max(" + maxKeyNumber(currentCash, ankaKeyPrice) + ") | 0: Change Key Type : ");
  114.                         int keyNumber = keyNumberBuy.nextInt();
  115.                         int boughtKeyPrice = keyNumber*ankaKeyPrice;
  116.                         double newCurrentCash = (currentCash)-(keyNumber*ankaKeyPrice);
  117.                        
  118.                         if (keyNumber==0) {
  119.                             System.out.println("--Logged Out!\n");
  120.                             break;
  121.                         }
  122.                        
  123.                         if (newCurrentCash >= 0 && keyNumber <= maxKeyNumber(currentCash, ankaKeyPrice)) {
  124.                             System.out.println("+Succes: You bought " + keyNumber + " Anka key and " + newCurrentCash + "$ cash left.");
  125.                             currentCash = newCurrentCash;
  126.                             ankakeybought = ankakeybought +keyNumber;
  127.                         }
  128.                        
  129.                         else {
  130.                             System.out.println("You can not buy more than max key value! Your cash is not enough!");
  131.                         }
  132.                        
  133.                     }
  134.                    
  135.                     else if (keyType == 4) {
  136.                         Scanner keyNumberBuy = new Scanner (System.in);
  137.                         System.out.print("How much key do you want? Max(" + maxKeyNumber(currentCash, revolverKeyPrice) + ") | 0: Change Key Type : ");
  138.                         int keyNumber = keyNumberBuy.nextInt();
  139.                         int boughtKeyPrice = keyNumber*revolverKeyPrice;
  140.                         double newCurrentCash = (currentCash)-(keyNumber*revolverKeyPrice);
  141.                        
  142.                         if (keyNumber==0) {
  143.                             System.out.println("--Logged Out!\n");
  144.                             break;
  145.                         }
  146.                        
  147.                         if (newCurrentCash >= 0 && keyNumber <= maxKeyNumber(currentCash, revolverKeyPrice)) {
  148.                             System.out.println("+Succes: You bought " + keyNumber + " Revolver key and " + newCurrentCash + "$ cash left.");
  149.                             currentCash = newCurrentCash;
  150.                             revolverkeybought = revolverkeybought +keyNumber;
  151.                         }
  152.                        
  153.                         else {
  154.                             System.out.println("You can not buy more than max key value! Your cash is not enough!");
  155.                         }
  156.                     }
  157.                    
  158.  
  159.                    
  160.                     else {
  161.                         System.out.println("Please enter valid key type number!\n");
  162.                         break;
  163.                     }
  164.                    
  165.                    
  166.                     }//while    
  167.                
  168.                
  169.                
  170.                
  171.             }
  172.            
  173.            
  174.             else {
  175.                 System.out.println("\n+Succes: You returned to start menu!\n");
  176.                 break;
  177.             }
  178.  
  179.             }//while
  180.            
  181.            
  182.            
  183.             //Credits System Ending Here!          
  184.            
  185.         }
  186.        
  187.         else if (menu==2) {
  188.            
  189.             //Kasa Açma Bölümü Burada Başlıyor
  190.            
  191.                // Kroma 3 Kasası Şans Değerleri
  192.             String[] kroma3 = new String[100];
  193.             String[] kroma2 = new String[100];
  194.             String[] anka = new String[100];
  195.             String[] revolver = new String[100];
  196.             //%50
  197.             for (int i = 0; i < 50; i++) {
  198.                 kroma3[i] = "Kroma 3 >> Iron Weapon";
  199.                 kroma2[i] = "Kroma 2 >> Iron Weapon";
  200.                 anka[i] = "Anka >> Iron Weapon";
  201.                 revolver[i] = "Revolver >> Iron Weapon";
  202.                
  203.             }
  204.             //%25
  205.             for (int i = 50; i < 75; i++) {
  206.                 kroma3[i] = "Kroma 3 >> Silver Weapon";
  207.                 kroma2[i] = "Kroma 2 >> Silver Weapon";
  208.                 anka[i] = "Anka >> Silver Weapon";
  209.                 revolver[i] = "Revolver >> Silver Weapon";
  210.                
  211.             }
  212.             //%20
  213.             for (int i = 75; i < 95; i++) {
  214.                 kroma3[i] = "Kroma 3 >> Gold Weapon";
  215.                 kroma2[i] = "Kroma 2 >> Gold Weapon";
  216.                 anka[i] = "Anka >> Gold Weapon";
  217.                 revolver[i] = "Revolver >> Gold Weapon";
  218.                
  219.             }
  220.             //%5
  221.             for (int i = 95; i <= 99; i++) {
  222.                 kroma3[i] = "Kroma 3 >> Titanium Weapon";
  223.                 kroma2[i] = "Kroma 2 >> Titanium Weapon";
  224.                 anka[i] = "Anka >> Titanium Weapon";
  225.                 revolver[i] = "Revolver >> Titanium Weapon";
  226.                
  227.             }
  228.            
  229.             // Silahların Kalitesi
  230.            
  231.             String[] weaponQuality = new String[100];
  232.             //%30
  233.             for (int i = 0; i < 30; i++) {
  234.                 weaponQuality[i] = " | Industrial Grade";
  235.                
  236.             }
  237.             //%30
  238.             for (int i = 30; i < 60; i++) {
  239.                 weaponQuality[i] = " | Restricted";
  240.                
  241.             }
  242.             //%25
  243.             for (int i = 60; i < 85; i++) {
  244.                 weaponQuality[i] = " | Classified";
  245.                
  246.             }
  247.             //%15
  248.             for (int i = 85; i < 99; i++) {
  249.                 weaponQuality[i] = " | Special Edition";
  250.                
  251.             }
  252.            
  253.             if (kroma3keybought>0 || kroma2keybought>0 || ankakeybought>0 || revolverkeybought>0) {
  254.                
  255.                
  256.                  System.out.println("\n1-Kroma 3 | 2-Kroma 2 | 3-Anka Operasyon | 4-Revolver Case | 5-Exit");
  257.                    
  258.                     boolean finish = false;
  259.                    
  260.                     while(finish==false) {
  261.                  
  262.                        
  263.                     Scanner s = new Scanner (System.in);    
  264.                     System.out.print("\nSelect the box which you want to open: ");
  265.                     int kutu = s.nextInt();
  266.                        
  267.                     Random w = new Random();
  268.                     int RandomWeapon = w.nextInt(100);
  269.                     Random q = new Random();
  270.                     int RandomWeaponQuality = q.nextInt(100);
  271.                  
  272.          
  273.                    if (kutu==1) {
  274.                        
  275.                        if (kroma3keybought>0) { //kroma3 anahtarı var mı kontrol et
  276.                            System.out.println("\n+You won new weapon: " + kroma3[RandomWeapon] + weaponQuality[RandomWeaponQuality]);
  277.                            guns.add(kroma3[RandomWeapon] + weaponQuality[RandomWeaponQuality]);
  278.                            gPrice.add(printWeaponPrice(RandomWeapon,RandomWeaponQuality));
  279.                            currentCash = printWeaponPrice(RandomWeapon,RandomWeaponQuality) + currentCash;
  280.                            kroma3keybought--;
  281.                         }
  282.                        
  283.                        else {
  284.                            System.out.println("\n-Fail: You do not have Kroma 3 Key!");
  285.                        }
  286.                        
  287.                        
  288.                     }
  289.                    
  290.                     else if (kutu==2) {
  291.                        
  292.                            if (kroma2keybought>0) { //kroma2 anahtarı var mı kontrol et
  293.                                System.out.println("\n+You won new weapon: " + kroma2[RandomWeapon] + weaponQuality[RandomWeaponQuality]);
  294.                                guns.add(kroma2[RandomWeapon] + weaponQuality[RandomWeaponQuality]);
  295.                                gPrice.add(printWeaponPrice(RandomWeapon,RandomWeaponQuality));
  296.                                currentCash = printWeaponPrice(RandomWeapon,RandomWeaponQuality) + currentCash;
  297.                                kroma2keybought--;
  298.                             }
  299.                            
  300.                            else {
  301.                                System.out.println("\n-Fail: You do not have Kroma 2 Key!");
  302.                            }
  303.                        
  304.                     }
  305.                    
  306.                     else if (kutu==3) {
  307.                        
  308.                            if (ankakeybought>0) { //anka anahtarı var mı kontrol et
  309.                                System.out.println("\n+You won new weapon: " + anka[RandomWeapon] + weaponQuality[RandomWeaponQuality]);
  310.                                guns.add(anka[RandomWeapon] + weaponQuality[RandomWeaponQuality]);
  311.                                gPrice.add(printWeaponPrice(RandomWeapon,RandomWeaponQuality));
  312.                                currentCash = printWeaponPrice(RandomWeapon,RandomWeaponQuality) + currentCash;
  313.                                ankakeybought--;
  314.                             }
  315.                            
  316.                            else {
  317.                                System.out.println("\n-Fail: You do not have Anka Key!");
  318.                            }
  319.                        
  320.                     }
  321.                    
  322.                     else if (kutu==4) {
  323.                            if (revolverkeybought>0) { //revolver anahtarı var mı kontrol et
  324.                                System.out.println("\n+You won new weapon: " + revolver[RandomWeapon] + weaponQuality[RandomWeaponQuality]);
  325.                                guns.add(revolver[RandomWeapon] + weaponQuality[RandomWeaponQuality]);
  326.                                gPrice.add(printWeaponPrice(RandomWeapon,RandomWeaponQuality));
  327.                                currentCash = printWeaponPrice(RandomWeapon,RandomWeaponQuality) + currentCash;
  328.                                
  329.                                revolverkeybought--;
  330.                             }
  331.                            
  332.                            else {
  333.                                System.out.println("\n-Fail: You do not have Revolver Key!");
  334.                            }
  335.                     }
  336.                    
  337.                     else if (kutu==5) {
  338.                        
  339.                         Scanner exit = new Scanner (System.in);
  340.                         System.out.println("Are you sure about the exit? [y,n]:");
  341.                         char exit2 = exit.nextLine().charAt(0);
  342.                         if (exit2 == 'y' || exit2 == 'Y' ) {
  343.                             break;
  344.                         }
  345.                        
  346.                         else {
  347.                             continue;
  348.          
  349.                         }
  350.                     }
  351.                    
  352.                     else if (kutu>=6) {
  353.                         System.out.println("Please choose correct case number!");
  354.                     }
  355.                    
  356.                    
  357.                    
  358.                     }
  359.                    
  360.                
  361.                
  362.                   //Kasa Açma Bölümü Burada Bitiyor
  363.                
  364.                
  365.             } //if bitti - kasa anahtarı varsa
  366.            
  367.                
  368.             else { //hiç kasa anahtarı yoksa
  369.                 System.out.println("-Fail: You don't have any key! Firstly, you have to buy key.\n");
  370.             }
  371.                
  372.            
  373.            
  374.         }
  375.         // silah satma fonksiyonu başlıyor
  376.        
  377.         else if (menu==3) {
  378.            
  379.             boolean sellgun = false;
  380.             printWeapons(size,guns,gPrice);
  381.            
  382.             while(sellgun == false) {
  383.            
  384.             Scanner sg = new Scanner (System.in);
  385.             System.out.println("Plaese enter the weapon ID to sell: ");
  386.             int sgchoice = sg.nextInt();
  387.            
  388.             if (sgchoice != 0) {
  389.             guns.remove(sgchoice-1);
  390.             gPrice.remove(sgchoice-1);
  391.             }
  392.            
  393.             else {
  394.                 break;
  395.             }
  396.            
  397.         }// sellgun while
  398.            
  399.         }//menu 3 bitti
  400.        
  401.         else  { //start menude 1,2 veya 3 dışında bir şeye basıldıysa
  402.             System.out.println("Please enter valid menu option!");
  403.         }
  404.        
  405.        
  406.        
  407.  
  408.     }//first while
  409.    
  410.    
  411.    
  412.    
  413.     }//main methods ending
  414.  
  415.    
  416.  
  417.     private static double printWeaponPrice(int RandomWeapon, int RandomWeaponQuality) {
  418.        
  419.          //Silah fiyatları
  420.         int ironWeaponPrice = 100;
  421.         int silverWeaponPrice = 200;
  422.         int goldWeaponPrice = 200;
  423.         int titaniumWeaponPrice = 400;
  424.         //Silah kalitesi katlayıcısı
  425.         double igPrice = 0.5;
  426.         double resPrice = 0.8;
  427.         double clasPrice = 1.5;
  428.         double specPrice = 3.5;
  429.         double weaponPrice = 0;
  430.        
  431.        
  432.         if (0<=RandomWeapon && RandomWeapon <50) {
  433.            if (0<=RandomWeaponQuality && RandomWeaponQuality<30) {
  434.                weaponPrice = ironWeaponPrice*igPrice;
  435.            }
  436.            
  437.            else if (30<=RandomWeaponQuality && RandomWeaponQuality<60) {
  438.                weaponPrice = ironWeaponPrice*resPrice;
  439.            }
  440.            
  441.            else if (60<=RandomWeaponQuality && RandomWeaponQuality<85) {
  442.                weaponPrice = ironWeaponPrice*clasPrice;
  443.            }
  444.            
  445.            else if (85<=RandomWeaponQuality && RandomWeaponQuality<99) {
  446.                weaponPrice = ironWeaponPrice*specPrice;
  447.            }
  448.            
  449.         }
  450.        
  451.         else if (50<=RandomWeapon && RandomWeapon <75) {
  452.            if (0<=RandomWeaponQuality && RandomWeaponQuality<30) {
  453.                weaponPrice = silverWeaponPrice*igPrice;
  454.            }
  455.            
  456.            else if (30<=RandomWeaponQuality && RandomWeaponQuality<60) {
  457.                weaponPrice = silverWeaponPrice*resPrice;
  458.            }
  459.            
  460.            else if (60<=RandomWeaponQuality && RandomWeaponQuality<85) {
  461.                weaponPrice = silverWeaponPrice*clasPrice;
  462.            }
  463.            
  464.            else if (85<=RandomWeaponQuality && RandomWeaponQuality<99) {
  465.                weaponPrice = silverWeaponPrice*specPrice;
  466.            }
  467.         }
  468.        
  469.         else if (75<=RandomWeapon && RandomWeapon <95) {
  470.            if (0<=RandomWeaponQuality && RandomWeaponQuality<30) {
  471.                weaponPrice = goldWeaponPrice*igPrice;
  472.            }
  473.            
  474.            else if (30<=RandomWeaponQuality && RandomWeaponQuality<60) {
  475.                weaponPrice = goldWeaponPrice*resPrice;
  476.            }
  477.            
  478.            else if (60<=RandomWeaponQuality && RandomWeaponQuality<85) {
  479.                weaponPrice = goldWeaponPrice*clasPrice;
  480.            }
  481.            
  482.            else if (85<=RandomWeaponQuality && RandomWeaponQuality<99) {
  483.                weaponPrice = goldWeaponPrice*specPrice;
  484.            }
  485.         }
  486.        
  487.         else if (95<=RandomWeapon && RandomWeapon <99) {
  488.            if (0<=RandomWeaponQuality && RandomWeaponQuality<30) {
  489.                weaponPrice = titaniumWeaponPrice*igPrice;
  490.            }
  491.            
  492.            else if (30<=RandomWeaponQuality && RandomWeaponQuality<60) {
  493.                weaponPrice = titaniumWeaponPrice*resPrice;
  494.            }
  495.            
  496.            else if (60<=RandomWeaponQuality && RandomWeaponQuality<85) {
  497.                weaponPrice = titaniumWeaponPrice*clasPrice;
  498.            }
  499.            
  500.            else if (85<=RandomWeaponQuality && RandomWeaponQuality<99) {
  501.                weaponPrice = titaniumWeaponPrice*specPrice;
  502.            }
  503.         }
  504.         return weaponPrice;
  505.     }
  506.  
  507.  
  508.  
  509.     private static ArrayList<String> printWeapons(int size,  ArrayList<String> guns, ArrayList<Double> gPrice) {
  510.         printWeaponsPrice(size, gPrice);
  511.         if (size == 0){
  512.             System.out.println("You don't have any weapon");
  513.         }
  514.        
  515.         else {
  516.             for (int i = 0; i < size; i++) {
  517.                 Object allweapons = guns.get(i);
  518.                 Object allweaponPrice = gPrice.get(i);
  519.                 System.out.println((i+1) + ": " + allweapons + "(" +allweaponPrice+"$)");
  520.             }
  521.         }
  522.        
  523.         return guns;
  524.     }
  525.    
  526.     private static ArrayList<Double> printWeaponsPrice(int size,  ArrayList<Double> gPrice) {
  527.         if (size == 0){
  528.            
  529.         }
  530.        
  531.         else {
  532.             for (int i = 0; i < size; i++) {
  533.                 Object allweaponsPrice = gPrice.get(i);
  534.             }
  535.         }
  536.        return gPrice;
  537.     }
  538.  
  539.  
  540.  
  541.     private static double maxKeyNumber(double currentCash, int x) {
  542.         double maxKeyNumber = currentCash/x;
  543.         return maxKeyNumber;
  544.        
  545.     }
  546.    
  547.  
  548.  
  549. }
Advertisement
Add Comment
Please, Sign In to add comment