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
- UserInformation
- VectorSearch
- arrayCheckAndCreate
- SoftwareEngineeringProject_3edooo_Main
this is the game logo

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





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