Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- import java.util.Random;
- import java.util.Scanner;
- public class CSGONew {
- public static void main(String[] args) {
- //Para Sistemi
- int totalCash = 100;
- double currentCash = 100;
- //Kasa anahtarı fiyatları
- int kroma3KeyPrice = 7;
- int kroma2KeyPrice = 5;
- int ankaKeyPrice = 3;
- int revolverKeyPrice = 4;
- //Varsayılan satın alınmış kasa sayısı
- int kroma3keybought = 0, kroma2keybought = 0, ankakeybought = 0, revolverkeybought = 0;
- //Döngüleri sonlandırmak için değişkenler
- boolean turnHead = false;
- boolean finall = false;
- boolean returnStart = false;
- //Silah envanteri için ArrayList
- ArrayList<String> guns = new ArrayList<String>();
- ArrayList<Double> gPrice = new ArrayList<Double>();
- //Program BAŞLIYOR...
- while (finall == false) {
- System.out.println("---[<<CASH INFO>>]---");
- System.out.println("Info: You have " + currentCash + "$ in your wallet. \n");
- // Anahter envanterini listesli hiç anahtarım yoksa boşa
- if (kroma3keybought == 0 && kroma2keybought == 0 && ankakeybought == 0 && revolverkeybought == 0) {
- System.out.println("---[<<KEYS>>]---\nYou don't have any key, press 1 to buy!");
- }
- else {
- 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);
- }
- System.out.println("\n---[<<WEAPONS>>]---");
- int size = guns.size();
- printWeapons(size,guns,gPrice);
- System.out.println("\n---[<<START PAGE MENU>>]---");
- System.out.print("1: To Buy Case Key\n2: To Open Case\n3: To sell weapon\n4: Refresh weapon list\n\n[!Process] Enter your choice:");
- Scanner mainmenu = new Scanner (System.in);
- int menu = mainmenu.nextInt();
- if (menu==1) {
- //Credit System is Starting
- while (turnHead == false && currentCash >= kroma3KeyPrice || currentCash >= kroma2KeyPrice || currentCash >= ankaKeyPrice || currentCash >= revolverKeyPrice) {
- 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 + "$)\n0:Return Start Menu");
- System.out.print("\n[!Process] Enter the type value: ");
- Scanner type = new Scanner (System.in);
- int keyType = type.nextInt();
- if (keyType!=0) {
- while (returnStart = false && currentCash >= kroma3KeyPrice || currentCash >= kroma2KeyPrice || currentCash >= ankaKeyPrice || currentCash >= revolverKeyPrice) {
- if (keyType == 1) {
- Scanner keyNumberBuy = new Scanner (System.in);
- System.out.print("\nHow much key do you want? Max(" + maxKeyNumber(currentCash, kroma3KeyPrice) + ") | 0: Change Key Type : ");
- int keyNumber = keyNumberBuy.nextInt();
- int boughtKeyPrice = keyNumber*kroma3KeyPrice;
- currentCash = (currentCash)-(keyNumber*kroma3KeyPrice);
- if (keyNumber==0) {
- System.out.println("\nInfo: You returned KEY MENU\n");
- break;
- }
- else if (currentCash >= 0 && keyNumber <= maxKeyNumber(currentCash, kroma3KeyPrice)) {
- System.out.println("+Succes: You bought " + keyNumber + " Kroma3 key and " + currentCash + "$ cash left.");
- kroma3keybought = kroma3keybought +keyNumber;
- }
- else {
- System.out.println("You can not buy more than max key value! Your cash is not enough!");
- }
- }
- else if (keyType == 2) {
- Scanner keyNumberBuy = new Scanner (System.in);
- System.out.print("How much key do you want? Max(" + maxKeyNumber(currentCash, kroma2KeyPrice) + ") | 0: Change Key Type : ");
- int keyNumber = keyNumberBuy.nextInt();
- int boughtKeyPrice = keyNumber*kroma2KeyPrice;
- currentCash = (currentCash)-(keyNumber*kroma2KeyPrice);
- if (keyNumber==0) {
- System.out.println("\nInfo: You returned KEY MENU\n");
- break;
- }
- if (currentCash >= 0 && keyNumber <= maxKeyNumber(currentCash, kroma2KeyPrice)) {
- System.out.println("+Succes: You bought " + keyNumber + " Kroma2 key and " + currentCash + "$ cash left.");
- kroma2keybought = kroma2keybought +keyNumber;
- }
- else {
- System.out.println("You can not buy more than max key value! Your cash is not enough!");
- }
- }
- else if (keyType == 3) {
- Scanner keyNumberBuy = new Scanner (System.in);
- System.out.print("How much key do you want? Max(" + maxKeyNumber(currentCash, ankaKeyPrice) + ") | 0: Change Key Type : ");
- int keyNumber = keyNumberBuy.nextInt();
- int boughtKeyPrice = keyNumber*ankaKeyPrice;
- currentCash = (currentCash)-(keyNumber*ankaKeyPrice);
- if (keyNumber==0) {
- System.out.println("-\nInfo: You returned KEY MENU\n");
- break;
- }
- if (currentCash >= 0 && keyNumber <= maxKeyNumber(currentCash, ankaKeyPrice)) {
- System.out.println("+Succes: You bought " + keyNumber + " Anka key and " + currentCash + "$ cash left.");
- ankakeybought = ankakeybought +keyNumber;
- }
- else {
- System.out.println("You can not buy more than max key value! Your cash is not enough!");
- }
- }
- else if (keyType == 4) {
- Scanner keyNumberBuy = new Scanner (System.in);
- System.out.print("How much key do you want? Max(" + maxKeyNumber(currentCash, revolverKeyPrice) + ") | 0: Change Key Type : ");
- int keyNumber = keyNumberBuy.nextInt();
- int boughtKeyPrice = keyNumber*revolverKeyPrice;
- currentCash = (currentCash)-(keyNumber*revolverKeyPrice);
- if (keyNumber==0) {
- System.out.println("\nInfo: You returned KEY MENU\n");
- break;
- }
- if (currentCash >= 0 && keyNumber <= maxKeyNumber(currentCash, revolverKeyPrice)) {
- System.out.println("+Succes: You bought " + keyNumber + " Revolver key and " + currentCash + "$ cash left.");
- revolverkeybought = revolverkeybought +keyNumber;
- }
- else {
- System.out.println("You can not buy more than max key value! Your cash is not enough!");
- }
- }
- else {
- System.out.println("Please enter valid key type number!\n");
- break;
- }
- }//while
- }
- else {
- System.out.println("\n+Succes: You returned to start menu!\n");
- break;
- }
- }//while
- //Credits System Ending Here!
- }
- else if (menu==2) {
- //Kasa Açma Bölümü Burada Başlıyor
- // Kroma 3 Kasası Şans Değerleri
- String[] kroma3 = new String[100];
- String[] kroma2 = new String[100];
- String[] anka = new String[100];
- String[] revolver = new String[100];
- //%50
- for (int i = 0; i < 50; i++) {
- kroma3[i] = "Kroma 3 >> Iron Weapon";
- kroma2[i] = "Kroma 2 >> Iron Weapon";
- anka[i] = "Anka >> Iron Weapon";
- revolver[i] = "Revolver >> Iron Weapon";
- }
- //%25
- for (int i = 50; i < 75; i++) {
- kroma3[i] = "Kroma 3 >> Silver Weapon";
- kroma2[i] = "Kroma 2 >> Silver Weapon";
- anka[i] = "Anka >> Silver Weapon";
- revolver[i] = "Revolver >> Silver Weapon";
- }
- //%20
- for (int i = 75; i < 95; i++) {
- kroma3[i] = "Kroma 3 >> Gold Weapon";
- kroma2[i] = "Kroma 2 >> Gold Weapon";
- anka[i] = "Anka >> Gold Weapon";
- revolver[i] = "Revolver >> Gold Weapon";
- }
- //%5
- for (int i = 95; i <= 99; i++) {
- kroma3[i] = "Kroma 3 >> Titanium Weapon";
- kroma2[i] = "Kroma 2 >> Titanium Weapon";
- anka[i] = "Anka >> Titanium Weapon";
- revolver[i] = "Revolver >> Titanium Weapon";
- }
- // Silahların Kalitesi
- String[] weaponQuality = new String[100];
- //%30
- for (int i = 0; i < 30; i++) {
- weaponQuality[i] = " | Industrial Grade";
- }
- //%30
- for (int i = 30; i < 60; i++) {
- weaponQuality[i] = " | Restricted";
- }
- //%25
- for (int i = 60; i < 85; i++) {
- weaponQuality[i] = " | Classified";
- }
- //%15
- for (int i = 85; i < 99; i++) {
- weaponQuality[i] = " | Special Edition";
- }
- if (kroma3keybought>0 || kroma2keybought>0 || ankakeybought>0 || revolverkeybought>0) {
- System.out.println("\n1:Kroma 3 | 2:Kroma 2 | 3:Anka Operasyon | 4:Revolver Case | 0:Exit");
- boolean finish = false;
- while(finish==false) {
- Scanner s = new Scanner (System.in);
- System.out.print("\n[!Process] Select the box which you want to open: ");
- int kutu = s.nextInt();
- Random w = new Random();
- int RandomWeapon = w.nextInt(100);
- Random q = new Random();
- int RandomWeaponQuality = q.nextInt(100);
- if (kutu==1) {
- if (kroma3keybought>0) { //kroma3 anahtarı var mı kontrol et
- System.out.println("\n+You won new weapon: " + kroma3[RandomWeapon] + weaponQuality[RandomWeaponQuality]);
- guns.add(kroma3[RandomWeapon] + weaponQuality[RandomWeaponQuality]);
- gPrice.add(printWeaponPrice(RandomWeapon,RandomWeaponQuality));
- kroma3keybought--;
- }
- else {
- System.out.println("\n-Fail: You do not have Kroma 3 Key!");
- }
- }
- else if (kutu==2) {
- if (kroma2keybought>0) { //kroma2 anahtarı var mı kontrol et
- System.out.println("\n+You won new weapon: " + kroma2[RandomWeapon] + weaponQuality[RandomWeaponQuality]);
- guns.add(kroma2[RandomWeapon] + weaponQuality[RandomWeaponQuality]);
- gPrice.add(printWeaponPrice(RandomWeapon,RandomWeaponQuality));
- kroma2keybought--;
- }
- else {
- System.out.println("\n-Fail: You do not have Kroma 2 Key!");
- }
- }
- else if (kutu==3) {
- if (ankakeybought>0) { //anka anahtarı var mı kontrol et
- System.out.println("\n+You won new weapon: " + anka[RandomWeapon] + weaponQuality[RandomWeaponQuality]);
- guns.add(anka[RandomWeapon] + weaponQuality[RandomWeaponQuality]);
- gPrice.add(printWeaponPrice(RandomWeapon,RandomWeaponQuality));
- ankakeybought--;
- }
- else {
- System.out.println("\n-Fail: You do not have Anka Key!");
- }
- }
- else if (kutu==4) {
- if (revolverkeybought>0) { //revolver anahtarı var mı kontrol et
- System.out.println("\n+You won new weapon: " + revolver[RandomWeapon] + weaponQuality[RandomWeaponQuality]);
- guns.add(revolver[RandomWeapon] + weaponQuality[RandomWeaponQuality]);
- gPrice.add(printWeaponPrice(RandomWeapon,RandomWeaponQuality));
- revolverkeybought--;
- }
- else {
- System.out.println("\n-Fail: You do not have Revolver Key!");
- }
- }
- else if (kutu==0) {
- Scanner exit = new Scanner (System.in);
- System.out.println("\n[!Process] Are you sure about the exit? [y,n]:");
- char exit2 = exit.nextLine().charAt(0);
- if (exit2 == 'y' || exit2 == 'Y' ) {
- break;
- }
- else {
- continue;
- }
- }
- else if (kutu>=6) {
- System.out.println("Please choose correct case number!");
- }
- }
- //Kasa Açma Bölümü Burada Bitiyor
- } //if bitti - kasa anahtarı varsa
- else { //hiç kasa anahtarı yoksa
- System.out.println("-Fail: You don't have any key! Firstly, you have to buy key.\n");
- }
- }
- // silah satma fonksiyonu başlıyor
- else if (menu==3) {
- boolean sellgun = false;
- printWeapons(size,guns,gPrice);
- while(sellgun == false) {
- Scanner sg = new Scanner (System.in);
- System.out.println("Plaese enter the weapon ID to sell [0: Return main menu]: ");
- int sgchoice = sg.nextInt();
- if (sgchoice < 0 || sgchoice > size) {
- System.out.println("Please enter the valid weapon ID!");
- }
- else {
- if (sgchoice != 0) {
- Object o = guns.get(sgchoice-1);
- double soldGunPrice = gPrice.get(sgchoice-1);
- if (o!= "SOLD!") {
- guns.set(sgchoice-1, "SOLD!");
- gPrice.set(sgchoice-1, 0.0);
- currentCash = soldGunPrice + currentCash;
- }
- else {
- System.out.println("You are already sold this item! Try another ID.");
- }
- }
- else {
- break;
- }
- }
- }// sellgun while
- }//menu 3 bitti
- else if (menu == 4) { // silah listesini yenile
- for (int i = 0; i < size; i++) {
- String a1 = guns.get(i);
- double a2 = gPrice.get(i);
- if (a1 == "SOLD!" && a2 == 0.0) {
- guns.remove(i);
- gPrice.remove(i);
- }
- int size2 = guns.size();
- size = size2;
- }
- }//menu 4 bitti
- else { //start menude 1,2 veya 3 dışında bir şeye basıldıysa
- System.out.println("Please enter valid menu option!");
- }
- }//first while
- }//main methods ending
- private static double printWeaponPrice(int RandomWeapon, int RandomWeaponQuality) {
- //Silah fiyatları
- int ironWeaponPrice = 100;
- int silverWeaponPrice = 200;
- int goldWeaponPrice = 200;
- int titaniumWeaponPrice = 400;
- //Silah kalitesi katlayıcısı
- double igPrice = 0.5;
- double resPrice = 0.8;
- double clasPrice = 1.5;
- double specPrice = 3.5;
- double weaponPrice = 0;
- if (0<=RandomWeapon && RandomWeapon <50) {
- if (0<=RandomWeaponQuality && RandomWeaponQuality<30) {
- weaponPrice = ironWeaponPrice*igPrice;
- }
- else if (30<=RandomWeaponQuality && RandomWeaponQuality<60) {
- weaponPrice = ironWeaponPrice*resPrice;
- }
- else if (60<=RandomWeaponQuality && RandomWeaponQuality<85) {
- weaponPrice = ironWeaponPrice*clasPrice;
- }
- else if (85<=RandomWeaponQuality && RandomWeaponQuality<99) {
- weaponPrice = ironWeaponPrice*specPrice;
- }
- }
- else if (50<=RandomWeapon && RandomWeapon <75) {
- if (0<=RandomWeaponQuality && RandomWeaponQuality<30) {
- weaponPrice = silverWeaponPrice*igPrice;
- }
- else if (30<=RandomWeaponQuality && RandomWeaponQuality<60) {
- weaponPrice = silverWeaponPrice*resPrice;
- }
- else if (60<=RandomWeaponQuality && RandomWeaponQuality<85) {
- weaponPrice = silverWeaponPrice*clasPrice;
- }
- else if (85<=RandomWeaponQuality && RandomWeaponQuality<99) {
- weaponPrice = silverWeaponPrice*specPrice;
- }
- }
- else if (75<=RandomWeapon && RandomWeapon <95) {
- if (0<=RandomWeaponQuality && RandomWeaponQuality<30) {
- weaponPrice = goldWeaponPrice*igPrice;
- }
- else if (30<=RandomWeaponQuality && RandomWeaponQuality<60) {
- weaponPrice = goldWeaponPrice*resPrice;
- }
- else if (60<=RandomWeaponQuality && RandomWeaponQuality<85) {
- weaponPrice = goldWeaponPrice*clasPrice;
- }
- else if (85<=RandomWeaponQuality && RandomWeaponQuality<99) {
- weaponPrice = goldWeaponPrice*specPrice;
- }
- }
- else if (95<=RandomWeapon && RandomWeapon <99) {
- if (0<=RandomWeaponQuality && RandomWeaponQuality<30) {
- weaponPrice = titaniumWeaponPrice*igPrice;
- }
- else if (30<=RandomWeaponQuality && RandomWeaponQuality<60) {
- weaponPrice = titaniumWeaponPrice*resPrice;
- }
- else if (60<=RandomWeaponQuality && RandomWeaponQuality<85) {
- weaponPrice = titaniumWeaponPrice*clasPrice;
- }
- else if (85<=RandomWeaponQuality && RandomWeaponQuality<99) {
- weaponPrice = titaniumWeaponPrice*specPrice;
- }
- }
- return weaponPrice;
- }
- private static ArrayList<String> printWeapons(int size, ArrayList<String> guns, ArrayList<Double> gPrice) {
- printWeaponsPrice(size, gPrice);
- if (size == 0){
- System.out.println("You don't have any weapon");
- }
- else {
- for (int i = 0; i < size; i++) {
- Object allweapons = guns.get(i);
- Object allweaponPrice = gPrice.get(i);
- System.out.println((i+1) + ": " + allweapons + "(" +allweaponPrice+"$)");
- }
- }
- return guns;
- }
- private static ArrayList<Double> printWeaponsPrice(int size, ArrayList<Double> gPrice) {
- if (size == 0){
- }
- else {
- for (int i = 0; i < size; i++) {
- Object allweaponsPrice = gPrice.get(i);
- }
- }
- return gPrice;
- }
- private static double maxKeyNumber(double currentCash, int x) {
- double maxKeyNumber = currentCash/x;
- int maxKeyNumberInt = (int) maxKeyNumber;
- return maxKeyNumberInt;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement