Hey, I'm making a program for my high school Comp Sci class with a partner.
Because we're beasts and finished the project on the second day we were looking to see if we could do any extra improvisation to keep us entertained and for possible extra credit.
So I was wondering if you guys knew how to do such a thing.
If anyone wants to see our awesome program here it is:
(Warning: contains extreme awesomeness)
import java.util.*;
public class luckyStripes {
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
Random generator = new Random();
int[][] board = new int [5][5];
int counter = 0;
int randRow;
int randCol;
int score = 0;
int totalScore = 0;
String cont = "Y";
while (cont.equals ("Y")){
while (counter < 5){
for (int row = 0; row < 5; row++){
for (int col = 0; col < 5; col++){
if (row == 0 || row == 4 || col == 0 || col == 4){
board[row][col] = 1;
}
}
}
for (int row = 1; row < 4; row++){
for(int col = 1 ; col < 4; col++){
board[row][col] = 2;
}
}
board [2][2] = 3;
randRow = generator.nextInt(5);
randCol = generator.nextInt(5);
if (board[randRow][randCol] == 1){
score += 1;
totalScore += 1;
}
if (board[randRow][randCol] == 2){
score += 2;
totalScore += 2;
}
if (board[randRow][randCol] == 3){
score += 3;
totalScore += 3;
}
board[randRow][randCol] = 0;
for (int row = 0; row < 5; row++){
for (int col = 0; col < 5; col++){
System.out.print(board[row][col] + "\t");
}
System.out.println("");
}
System.out.println("");
System.out.println("The score so far is: " + score);
System.out.println("The total score for all games so far is: " + totalScore);
System.out.println("");
counter++;
}
score = 0;
counter = 0;
System.out.print("Would you like to play again? (Y/N): ");
cont = keyboard.nextLine();
cont = cont.toUpperCase();
while (!(cont.equals("Y") || (cont.equals("N")))){
System.out.println("You must input either letter Y or N!");
System.out.print("Would you like to play again? (Y/N): ");
cont = keyboard.nextLine();
cont = cont.toUpperCase();
}
if (cont.equals("N"))
System.out.println("Thanks for playing!");
}
}
}
Because we're beasts and finished the project on the second day we were looking to see if we could do any extra improvisation to keep us entertained and for possible extra credit.
So I was wondering if you guys knew how to do such a thing.
If anyone wants to see our awesome program here it is:
(Warning: contains extreme awesomeness)
import java.util.*;
public class luckyStripes {
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
Random generator = new Random();
int[][] board = new int [5][5];
int counter = 0;
int randRow;
int randCol;
int score = 0;
int totalScore = 0;
String cont = "Y";
while (cont.equals ("Y")){
while (counter < 5){
for (int row = 0; row < 5; row++){
for (int col = 0; col < 5; col++){
if (row == 0 || row == 4 || col == 0 || col == 4){
board[row][col] = 1;
}
}
}
for (int row = 1; row < 4; row++){
for(int col = 1 ; col < 4; col++){
board[row][col] = 2;
}
}
board [2][2] = 3;
randRow = generator.nextInt(5);
randCol = generator.nextInt(5);
if (board[randRow][randCol] == 1){
score += 1;
totalScore += 1;
}
if (board[randRow][randCol] == 2){
score += 2;
totalScore += 2;
}
if (board[randRow][randCol] == 3){
score += 3;
totalScore += 3;
}
board[randRow][randCol] = 0;
for (int row = 0; row < 5; row++){
for (int col = 0; col < 5; col++){
System.out.print(board[row][col] + "\t");
}
System.out.println("");
}
System.out.println("");
System.out.println("The score so far is: " + score);
System.out.println("The total score for all games so far is: " + totalScore);
System.out.println("");
counter++;
}
score = 0;
counter = 0;
System.out.print("Would you like to play again? (Y/N): ");
cont = keyboard.nextLine();
cont = cont.toUpperCase();
while (!(cont.equals("Y") || (cont.equals("N")))){
System.out.println("You must input either letter Y or N!");
System.out.print("Would you like to play again? (Y/N): ");
cont = keyboard.nextLine();
cont = cont.toUpperCase();
}
if (cont.equals("N"))
System.out.println("Thanks for playing!");
}
}
}