Skip to main content

Posts

Showing posts from July, 2013

Is there a God In Tamil Dr. Zakir Naik Part 2 of 2

Game Entry

***************************************************************************
public class GameEntry{
public String name;
public int score;

public GameEntry(String n, int s){
name = n;
score = s;
}

public String getName(){
return name;
}

public int getScore(){
return score;
}

public String toString(){
return "("+name+","+score+")";
}

}
**************************************************************************
import java.util.Scanner;
public class Scores{
public static final int maxEntries = 10;
public GameEntry[] entries;
public int numEntries;

public Scores(){
entries = new GameEntry[maxEntries];
numEntries =0;
}

public void setEntry(String name, int score){
GameEntry gE  = new GameEntry(name,score);
if(numEntries ==0){
entries[numEntries] = gE;
numEntries++;
}
else if(numEntries >0 && numEntries !=0 && numEntries<=10){
entries[numEntries] = gE;
for(int i=numEntries; i>0; i--){
if(entries[i].getScore() > entries[i-1].getScore()){
GameEntry temp =entries[i];
entries[…

Hole with Random Generator

import java.util.Scanner;
public class randomHole{
String[][] holeStore;
static int Ncol=5;
static int Nrow=3;
int token;
randomHole(){
holeStore = new String[Nrow][Ncol];
for(int i=0; i<Nrow; i++){
for(int j=0; j<Ncol; j++){
holeStore[i][j] = "Free";
}

}
}

void set_full(int row,int col){
findToken();
boolean valid_token = false;
for(int i=0; i<Nrow; i++){
for(int j=0; j<Ncol; j++){
if(holeStore[i][j] == Integer.toString(token)){
set_full(row,col);
}
else{
valid_token = true;
}
}
}
if(valid_token){
holeStore[row-1][col-1] = Integer.toString(token);
System.out.println("Your Token is : "+token);
}
}

void set_Null(int row, int col){
holeStore[row-1][col-1] = "Free";
}
void findHole(int token){
boolean is_found = false;
for(int i=0; i<Nrow; i++){
for(int j=0; j<Ncol; j++){
if( holeStore[i][j].equals(Integer.toString(token))){
int row = i+1;
int col = j+1;
System.out.println("Your Row is : "+row);
System.out.println("Your Colum is "+col);
is_found = true;
}
}
}
if(is_f…

Hole without random

import java.util.Scanner;
public class hole2{
String[][] holeStore;
int Ncol=5;
int Nrow=3;
int token;
hole2(){
holeStore = new String[Nrow][Ncol];
for(int i=0; i<Nrow; i++){
for(int j=0; j<Ncol; j++){
holeStore[i][j] = "Free";
}

}
}

void set_full(int row,int col){
findToken(row,col);
holeStore[row-1][col-1] = Integer.toString(token);
}

void set_Null(int row, int col){
holeStore[row-1][col-1] = "Free";
}
void findHole(int token){
boolean is_found = false;
for(int i=0; i<Nrow; i++){
for(int j=0; j<Ncol; j++){
if( holeStore[i][j].equals(Integer.toString(token))){
int row = i+1;
int col = j+1;
System.out.println("Your Row is : "+row);
System.out.println("Your Colum is "+col);
is_found = true;
     break;
}
}
}
if(is_found == false){
System.out.println("Sorry Your Token Not Found!\nTry Again.");
}
}

void findToken(int row, int col){
token = (row-1)*Ncol+col;
System.out.println("Your Token Is : "+token);
}

void find_free(){
for(int i=0; i<Nrow; i++){
for(in…

Selection Sort

these picture shows that the algorithm of the selection sort the code is below in (java)
******************************************************************
public class selectionSort{
public void sort(int[] A){
for(int i=0; i<A.length; i++){
int minIndex =i;
for(int j=i; j<A.length; j++){
if(A[minIndex] > A[j]){
minIndex = j;
}
}
   // Swapping the minIndex Element and first element 
int temp = A[i];
A[i] = A[minIndex];
A[minIndex] = temp;
}
}
}
******************************************************************

public class selectionSortDemo{
public static void main(String args[]){
int A[] = {7,3,2,5,1};
selectionSort S = new selectionSort();
S.sort(A);
for(int i=0; i<A.length; i++){
System.out.print(A[i]+" ");
}
}

}
******************************************************************************

Bubble Sort in Java

Bubble Sort is a simple sorting algorithm. It repeatedly comparing each of the adjacent pair and swap them like the above animation. 

An A-Z Index of the Bash command line for Linux.

alias Create an alias • apropos Search Help manual pages (man -k) apt-get Search for and install software packages (Debian/Ubuntu) aptitude Search for and install software packages (Debian/Ubuntu) aspell Spell Checker awk Find and Replace text, database sort/validate/index b basename Strip directory and suffix from filenames bash GNU Bourne-Again SHell bc Arbitrary precision calculator language bg Send to background break Exit from a loop • builtin Run a shell builtin bzip2 Compress or decompress named file(s) c cal Display a calendar case Conditionally perform a command cat Concatenate and print (display) the content of files cd Change Directory cfdisk Partition table manipulator for Linux chgrp Change group ownership chmod Change access permissions chown Change file owner and group chroot Run a command with a different root directory chkconfig System services (runlevel)�…