mardi 15 août 2017

How to make an if else-if test for something in a string and delete or change something (in java)

What I am talking about is something like this:

if (game == tdm) {
  scoret1 = scoret1 - 100;
}

If it helps, my code is listed below:

import java.util.Random;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Set;
import java.util.HashSet;
import java.util.Collections;
import java.util.List;

public class codGame {
  public static void main(String[] args) {
    Random me = new Random();
    ArrayList<String> gun = new ArrayList(Arrays.asList("KN-44","XR2","HVK-30","ICR-1","Man-O-War","Sheiva","M8A7"));
    ArrayList<String> player = new ArrayList(Arrays.asList("BlazeDaBlur","CoolCreeper707","BlurWINSTheGame","QTD","DomIsWhiteTiger","AdvisoryStorm","CadenGaming10","Andrew","gotem","tgg","hahsal","TheOneAndTheOnly20"));
    ArrayList<String> attachments = new ArrayList(Arrays.asList("Quickdraw","Grip","Extended Mag","Fast Mag","Rapid Fire","Suppressor","Long Barrel"));
    ArrayList<String> optics = new ArrayList(Arrays.asList("Reflex","Recon","Varix-3","Boa-3","Thermal","ELO"));
    ArrayList<String> maps = new ArrayList(Arrays.asList("Aquarium","Breach","Combine","Evac","Exodus","Fringe","Havoc","Hunted","Infection","Metro","Redwood","Stronghold","Nuk3town"));
    ArrayList<String> modes = new ArrayList(Arrays.asList("TDM","Domination","Free-For-All"));

    List<String> players = Arrays.asList("BlazeDaBlur","CoolCreeper707","BlurWINSTheGame","QTD","DomIsWhiteTiger","AdvisoryStorm","CadenGaming10","Andrew","gotem","tgg","hahsal","TheOneAndTheOnly20");

    Set guns = new HashSet(Arrays.asList(gun));
    Set play = new HashSet(Arrays.asList(player));
    Set att = new HashSet(Arrays.asList(attachments));
    Set opt = new HashSet(Arrays.asList(optics));
    Set map = new HashSet(Arrays.asList(maps));
    Set mode = new HashSet(Arrays.asList(modes));

    Collections.shuffle(players);
    Collections.shuffle(player);
    for (int i=0; i < 11; ++i) {
    player.remove(0);
    }
    Collections.shuffle(gun);
    for (int i=0; i < 6; ++i) {
    gun.remove(0);
    }
    Collections.shuffle(optics);
    for (int i=0; i < 5; ++i) {
    optics.remove(0);
    }
    Collections.shuffle(attachments);
    for (int i=0; i < 5; ++i) {
    attachments.remove(0);
    }
    Collections.shuffle(maps);
    for (int i=0; i < 12; ++i) {
    maps.remove(0);
    }
    Collections.shuffle(modes);
    for (int i=0; i < 2; ++i) {
    modes.remove(0);
    }

    int scoret1 = me.nextInt(200);
    int scoret2 = me.nextInt(200);

    List<String> blackops = players.subList(0, 6);
    List<String> cdp = players.subList(6, 12);

    System.out.println("BlackOps3 game.");
    System.out.println("");
    System.out.println("CDP team: " + cdp);
    System.out.println("");
    System.out.println("Black Ops team: " + blackops);
    System.out.println("");
    System.out.println("You are: " + play);
    System.out.println("");
    System.out.println("Your gun: " + guns + ", your attachments: " + att + ", and your optic: " + opt);
    System.out.println("");
    System.out.println("The map: " + map);
    System.out.println("");
    System.out.println("The mode: " + mode);
    System.out.println("");
    System.out.println("The score: " + scoret1 + " to " + scoret2);
    }
}

To get into a little bit more detail, if you have ever played BO3, you might know that Free-For-All has a score limit of 30, sometimes if I compile this, the gamemode is Free-For-All and I get: score: 180 to 100, which I am trying to fix with this question.




Aucun commentaire:

Enregistrer un commentaire