Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.awt.*;
- import java.util.Random;
- import java.util.Scanner;
- /*
- 1 == O || This is the player
- 2 == X || This is the bot
- 0 == / || This means nothing is selected
- */
- class boxNumbers {
- int boxOne = 0;
- int boxTwo = 0;
- int boxThree = 0;
- int boxFour = 0;
- int boxFive = 0;
- int boxSixe = 0;
- int boxSeven = 0;
- int boxEight = 0;
- int boxNine = 0;
- public int getBoxOne() {
- return boxOne;
- }
- public int getBoxTwo() {
- return boxTwo;
- }
- public int getBoxThree() {
- return boxThree;
- }
- public int getBoxFour() {
- return boxFour;
- }
- public int getBoxFive() {
- return boxFive;
- }
- public int getBoxSixe() {
- return boxSixe;
- }
- public int getBoxSeven() {
- return boxSeven;
- }
- public int getBoxEight() {
- return boxEight;
- }
- public int getBoxNine() {
- return boxNine;
- }
- public int setBoxOne(int setBoxOne) {
- setBoxOne = boxOne;
- return setBoxOne;
- }
- public int setBoxTwo(int setBoxTwo) {
- setBoxTwo = boxTwo;
- return setBoxTwo;
- }
- public int setBoxThree(int setBoxThree) {
- setBoxThree = boxThree;
- return setBoxThree;
- }
- public int setBoxFour(int setBoxFour) {
- setBoxFour = boxFour;
- return boxFour;
- }
- public int setBoxFive(int setBoxFive) {
- setBoxFive = boxFive;
- return boxFive;
- }
- public int setBoxSix(int setBoxSix) {
- setBoxSix = boxSixe;
- return setBoxSix;
- }
- public int setBoxSeven(int setBoxSeven) {
- setBoxSeven = boxSeven;
- return setBoxSeven;
- }
- public int setBoxEight(int setBoxEight) {
- setBoxEight = boxEight;
- return setBoxEight;
- }
- public int setBoxNine(int setBoxNine) {
- setBoxNine = boxNine;
- return setBoxNine;
- }
- }
- public class Main {
- public static void emptyBoard () {
- System.out.println(" | | ");
- System.out.println(" | | ");
- System.out.println(" | | ");
- System.out.println("___________________");
- System.out.println(" | | ");
- System.out.println(" | | ");
- System.out.println(" | | ");
- System.out.println("___________________");
- System.out.println(" | | ");
- System.out.println(" | | ");
- System.out.println(" | | ");
- }
- public static void main(String[] args) {
- Scanner reader = new Scanner(System.in);
- System.out.println("Welcome to Tic-Tac-Toe");
- System.out.println("Please select your difficulty");
- System.out.println("Easy | Hard");
- String userDifficulty = reader.nextLine();
- if (userDifficulty.equalsIgnoreCase("easy")) {
- System.out.println("Easy Mode Selected");
- easyMode();
- }
- if (userDifficulty.equalsIgnoreCase("hard")) {
- System.out.println("Hard Mode Selected");
- }
- }
- public static void boxSelection() {
- Scanner reader = new Scanner(System.in);
- int boxSelection = reader.nextInt();
- boxNumbers box = new boxNumbers();
- if (boxSelection == 1) {
- if (box.boxOne == 0){
- box.boxOne = 1;
- System.out.println(box.boxOne);
- return;
- }
- if (box.boxOne == 1){
- System.out.println("You already have that box!");
- boxSelection();
- }
- if (box.boxOne == 2) {
- System.out.println("That box is taken!");
- boxSelection();
- }
- }
- if (boxSelection == 2) {
- if (box.boxTwo == 0) {
- box.boxTwo = 1;
- System.out.println(box.boxTwo);
- return;
- }
- if (box.boxTwo == 1) {
- System.out.println("You already have this box!");
- boxSelection();
- }
- if (box.boxTwo == 2) {
- System.out.println("That box is already taken!");
- boxSelection();
- }
- }
- }
- public static void easyMode () {
- //Boxes corresponding to numbers
- //If box = 1, that is X
- //If box = 2, that is O
- //If box = 0, that is no-one
- int boxOne = 0;
- int boxTwo = 0;
- int boxThree = 0;
- int boxFour = 0;
- int boxFive = 0;
- int boxSIx = 0;
- int boxSeven = 0;
- int boxEight = 0;
- int boxNine = 0;
- Scanner reader = new Scanner(System.in);
- System.out.println("It's your turn, choose a number corresponding to a box on the board!");
- boxSelection();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement