Bingo Game in JAVA Working with vectors

Good night

today i bring to you very funny java program called (Bingo)

it is some kind of luck games

the idea of game is to generate random ( 0 or 1 )

if there is three ones ( the same row, column, diagonal ) then BINGO

else NOT BINGO

the game done using Vectors that is the purpose of it sorting, search, add, remove… etc:

لمحة سريعة باللغة العربية

البرنامج هو عبارة عن لعبة حظ بسيطة . تقوم بتوليد رقم عشوائي اما صفر او واحد

ثم تنظر الى الارقام في مصفوقفة ثلاثية فإذا كانت ثلاثة واحدات في نفس السطر او العمود او القطر نزبح ونزيد واحد ,إلا نخسر

i made it using NetBeans and consists of these classes

  1. UserInformation
  2. VectorSearch
  3. arrayCheckAndCreate
  4. SoftwareEngineeringProject_3edooo_Main

this is the game logo

eadoking com bingo Bingo Game in JAVA Working with vectors

UserInformation.java

package eadoking.sofowareEngineeringProject;

/**
*
* @author  Eadoking
* @website http://eadoking.com
* @email   eadoking@yahoo.com
* @email   info@eadoking.com
* @mobile  +963 932728084
*/

public class UserInformation implements Comparable {

private final int COMPARE_BY_SCORE = 0;
private final int COMPARE_BY_NAME = 1;
private final int COMPARE_BY_ACCESS_TIMES = 2;
private String userName;
private int valueOfScores;
private int valueOfAccessTimes;
private static int COMPARE_BY;

public UserInformation(String name) {
this.userName = name;
}

public String getUserName() {
return userName;
}

public int getScore() {
return valueOfScores;
}

public int getAccessTimes() {
return valueOfAccessTimes;
}

public static void setComAboutWhat(int COMPARE_BY) {
UserInformation.COMPARE_BY = COMPARE_BY;
}

public void increaseScore() {
valueOfScores++;
}

public void increaseAccessTimes() {
valueOfAccessTimes++;
}

public void setScore(int valueOfScores) {
this.valueOfScores = valueOfScores;
}

public void setAccessTimes(int valueOfAccessTimes) {
this.valueOfAccessTimes = valueOfAccessTimes;
}

public void setUserName(String userName) {
this.userName = userName;
}

public int compareTo(UserInformation userInformation) {
//throw new UnsupportedOperationException("Not supported yet.");
if (COMPARE_BY == COMPARE_BY_SCORE) {
return -(getScore() - userInformation.getScore());
} else if (COMPARE_BY == COMPARE_BY_NAME) {
return -(getUserName().compareTo(userInformation.getUserName()));
} else if (COMPARE_BY == COMPARE_BY_ACCESS_TIMES) {
return -(getAccessTimes() - userInformation.getAccessTimes());
} else {
return 0;
}
}
}


VectorSearch.java

package eadoking.sofowareEngineeringProject;

import java.util.Vector;

/**
*
* @author  Eadoking
* @website http://eadoking.com
* @email   eadoking@yahoo.com
* @email   info@eadoking.com
* @mobile  +963 932728084
*/

public class VectorSearch {
public static int search(Vector v, String name) {
UserInformation temp;
int index = -1;
for (int i = 0; i < v.size(); i++) {
temp = (UserInformation) v.get(i);
if (temp.getUserName().equalsIgnoreCase(name)) {
index = i;
break;

}
}

return index;
}

}

arrayCheckAndCreate.java

package eadoking.sofowareEngineeringProject;

import java.util.Random;

/**
*
* @author  Eadoking
* @website http://eadoking.com
* @email   eadoking@yahoo.com
* @email   info@eadoking.com
* @mobile  +963 932728084
*/
public class arrayCheckAndCreate {

public static int getRandomBit() {
Random r = new Random();
return r.nextInt(2);
}

public static int[][] getArray() {

int[][] temp = new int[3][3];
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
temp[i][j] = getRandomBit();
}
}

return temp;
}

public static boolean isRowOK(int i, int[][] arr) {

if ((arr[i][0]) == 1) {
if ((arr[i][1]) == 1) {
if ((arr[i][2]) == 1) {
return true;
}
}
}

return false;

}

public static boolean isColumnOK(int j, int[][] arr) {

if ((arr[0][j]) == 1) {
if ((arr[1][j]) == 1) {
if ((arr[2][j]) == 1) {
return true;
}
}
}
return false;

}

public static boolean isDiagonalsOK(int[][] arr) {

// Diagonal \
if (arr[0][0] == 1) {
if (arr[1][1] == 1) {
if (arr[2][2] == 1) {

return true;
}
}
}

// Diagonal /
if (arr[0][2] == 1) {
if (arr[1][1] == 1) {
if (arr[2][0] == 1) {
return true;
}
}
}

return false;

}

public static boolean checkTrue(int[][] arr) {
for (int i = 0; i < 3; i++) {
if (isRowOK(i, arr)) {

return true;

}
}

for (int j = 0; j < 3; j++) {
if (isColumnOK(j, arr)) {

return true;
}
}

if (isDiagonalsOK(arr)) {
return true;
}

return false;

}
}

downlaod the full code from here

and open it in NetBeans

Download

Tags: , , , , , , , , , , , , , , , , , , , ,

About eadoking

Ead AlDoukanje - EADOKING - 3edoOo ( عيد الدكنجي Studied Informatics Engineering at Tishreen University ( Software Engineering Department ) Work as freelancer Web Developer / Software Developer You can contact me to me@eadoking.com mobile : ( +963 ) 0932728084 Programming Skills : Java, C# , C++ , Java Server Pages (JSP ) with SERVLETS, PHP ,HTML , CSS ,JAVA SCRIPT with Ajax , ASP.NET , Web Services .

Stay in touch

subscribe with us using social media or email to stay updated
you can also contact us if you need some request or any thing to ,
http://me.eadoking.com/contact-me

Discuss: “Bingo Game in JAVA Working with vectors”

  1. August 27, 2009 at 9:54 pm #

    صحيح انسيت ما قلكون اي استفسار – او شي غير واضح اسالو فووووووووووورا

    Posted by eadoking
  2. August 27, 2009 at 6:54 pm #

    صحيح انسيت ما قلكون اي استفسار – او شي غير واضح اسالو فووووووووووورا

    Posted by eadoking

Leave a Reply


*