Thursday 20 April 2017

House game in java (Gui version )

PLAY HOUSIE:

package housiegame;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
public class Playhousie1 extends Frame implements ActionListener{
public static int n;
private static final long serialVersionUID = 1L;
public static Button [] board=new Button[100];
public Ticket1 t[];
public int jflag[],r1flag[],r2flag[],r3flag[],hflag[],count[];
public static boolean fjflag,frflag[],fhflag;
public Playhousie1(int n){
jflag=new int[n+1];
r1flag=new int[n+1];
r2flag=new int[n+1];
r3flag=new int[n+1];
hflag=new int[n+1];
count=new int[n+1];
t=new Ticket1[n+1];
for(int i=1;i<=n;i++)
t[i]=new Ticket1();
Button start=new Button("start");
this.setSize(500,500);
this.add(start);

start.addActionListener(this);
start.setVisible(true);
for(int i=1;i<=99;i++)
this.add(board[i]);

this.setLayout(new FlowLayout());
this.setVisible(true);
}
public static void main(String[] args){
frflag=new boolean[4];

for(int i=1;i<=99;i++){
board[i]=new Button(String.valueOf(i));
board[i].setBackground(Color.red);
board[i].setVisible(true);

}

Scanner cin=new Scanner(System.in);
System.out.println("enter no of players");
n=cin.nextInt();
new Playhousie1(n);
                 
}

public void actionPerformed(ActionEvent e){

Button b=(Button)e.getSource();
if(b.getLabel().equals("start")){

System.out.println("start");

return;
}
else{
int r=Integer.parseInt(b.getLabel());
int row=0;

if((board[r].getBackground()).equals(Color.green)){return;}

else{                                //checking number in every ticket
board[r].setBackground(Color.green);  //board[r]=1;
for(int i=1;i<=n;i++){
int k=r/10;
                 //searching number
    if(k==0){
for(int j=1;j<=3;j++){
if(Integer.parseInt(t[i].ticket[j][0].getLabel())==r){
row=j;
t[i].ticket[j][0].setLabel(String.valueOf(0)); //p[i].t.t[j][0])=0;
count[i]=count[i]+1;
break;
}
}
}
else {
for(int j=1;j<=3;j++){
if(Integer.parseInt(t[i].ticket[j][k].getLabel())==r){//(p[i].t.t[j][k])==r){
row=j;
t[i].ticket[j][k].setLabel(String.valueOf("0"));//(p[i].t.t[j][k])=0;
count[i]=count[i]+1;
break;

}
}
}                   
             //checking for any jaldee
if(count[i]<5){
                             continue;
}
                      
if(!fjflag && count[i]==5){
//number.setText("player"+ i +"wins jaldee");//System.out.println("player" + i + "wins jaldee \n");
jflag[i]=1;

}
                  //checking for row
if(count[i]>=5){
switch(row) {
                        case 1: if(!frflag[row]){          //first row
           if(check(i,row)){
   r1flag[i]=1;
   //l1.setText("player"+ i +"wins row" + row); //System.out.println("player" + i + "wins row"+ row);
       } 
} break;
case 2: if(!frflag[row]){        //second row
        if(check(i,row)){           
      r2flag[i]=1;
      //l2.setText("player"+ i +"wins row" + row);   //System.out.println("player" + i + "wins row"+ row);

        }
        }
       break;
case 3: if(!frflag[row]){        //third row
        if(check(i,row)){
r3flag[i]=1;
//l3.setText("player"+ i +"wins row" + row);//System.out.println("player" + i + "wins row "+row);
}
        }
break;
            }
if(count[i]==15){
hflag[i]=1;
     this.setTitle("PLAYER"+i+"WINS HOUSIE");//System.out.println("player "+ i + "wins housie");

}
                      
}
                           
                                            
}
                 //checking any thing happened after the random number "r"
if(!fjflag){
                    for(int i=1;i<=n;i++){    //jaldee
if(jflag[i]==1){
fjflag=true;
break;
}
}
}
                  
                    if(!frflag[1]){ //row1
    for(int i=1;i<=n;i++){
 if(r1flag[i]==1){
frflag[1]=true;
   break;
     }
    }
    }

if(!frflag[2]){
 for(int i=1;i<=n;i++){  //row2
if(r2flag[i]==1){
frflag[2]=true;
   break;
}
 }
}
if(!frflag[3]){
  for(int i=1;i<=n;i++){  //row3
if(r3flag[i]==1){
frflag[3]=true;
   break;
}
  }
}
int gameflag=0;
for(int i=1;i<=n;i++){
if(hflag[i]==1){
this.setBackground(Color.green);//System.out.println("game completed");
gameflag=1;//System.exit(0);
}
}
                 if(gameflag==1){}
                  //break;
}
}
}

public boolean check(int i,int row){
for(int column=0;column<=9;column++){
if(Integer.parseInt(t[i].ticket[row][column].getLabel())!=0)           //(p[i].t.t[row][column])!=0)
  return false;

return true;

}
}

TICKET:

package housiegame;
import java.awt.*;
import java.util.*;

public class Ticket1 extends Frame {
/**
 *
 */

private static final long serialVersionUID = 1L;
public Button [][] ticket=new Button[4][10];
public Ticket1(){
for(int  i=1;i<=3;i++){
for(int j=0;j<=9;j++){
ticket[i][j]=new Button("0");
this.add(ticket[i][j]);
ticket[i][j].setVisible(true);

}
this.setVisible(true);
this.setLayout(new GridLayout(3,9));
}
this.generateTicket();
}
public void generateTicket(){

Random random = new Random();
int r,j;

for(int i=1;i<=3;i++){
int countcolumn[]=new int[10];
for(int rowcount=0;rowcount<5; ){

j=random.nextInt(10);  //random(max-min+1)+min
if(countcolumn[j]==0){
if(j==0)
r=random.nextInt(9-1+1)+1;
else
r=random.nextInt(9+1)+(j)*10;

switch(i){

case 1:
ticket[i][j].setLabel(String.valueOf(r));  //ticket[i][j]=r;
countcolumn[j]=1;
rowcount++;
               break;
case 2: if (Integer.parseInt(ticket[i-1][j].getLabel())!=r) {    //t[i-1][j]!=r)
ticket[i][j].setLabel(String.valueOf(r)); //t[i][j]=r;
countcolumn[j]=1;
rowcount++;
}
         break;

case 3:
if((Integer.parseInt(ticket[i-1][j].getLabel())!=r)&& (Integer.parseInt(ticket[i-2][j].getLabel())!=r)){
ticket[i][j].setLabel(String.valueOf(r)); //t[i][j]=r;
countcolumn[j]=1;
rowcount++;

}
break;

}
}
}
}
}

public static void main(String[] args){
     Frame f=new Frame();
   Scanner cin=new Scanner(System.in);
   System.out.println("enter no of tickets");
   int n=cin.nextInt();
  Ticket1 t[]=new Ticket1[n];
  for(int i=0;i<n;i++){
   t[i]=new Ticket1();
   f.add(t[i]);
   }
  f.setLayout(new FlowLayout());
 f.setVisible(true);
 

}



Wednesday 19 April 2017

KHAT AAYA HAI | Award Winning Short Film | Aghaaz Productions | 2017

Manual Scavenging in India











My opinion on Manual Scavenging in India  :   This is not a project file or any programming code , the below code embeds my opinion on manual scavenging in India.....      plzzz comment your opinion on manual scavenging in India after understanding the below code and watching the videos .....


class Parent_ManualScavenger throws  DonotCleanMyHouse,Street,Toilet,RoadException{

public Home h[];
public Road r[];
public Street s[];
public static String cast;            //entire class qualifies with its cast

public String name;

String myWork(Home h,Road r,Street s,Toilet t){        //this is our work

h.clean();  //clean every home
r.clean();  // cleans every road
s.clean();  // cleans every street
t.clean();  // cleans every toilet
return "every thing is cleaned and manual scavenging is my work";
}



String fightAgainstGoverment(Public p){

 String status=p.letsFight();         //Fight Against Government

return status;
}

}



class Child_ManualScravenger extends Parent_ManualScavenger throws     DonotCleanMyHouse,Street,Toilet,RoadException{

public static String cast;                      // we are too qualified with our cast

public String name;

String doyourwork(){

Home h=new Home;
Road r=new Road;
Toilet t=new Toilet;
Street s=new Street;

String workStatus=super.myWork(h,r,s,t);      /* even i  want to do mywork because that i am                                                                         child of a manual scavenger i do my parents job only */
                                                                                  

return workstatus;
}

String fightAgainstGoverment(Public p){

 String status=p.letsFight();         //Fight Against Government

return status;
}

}


public class Public{


Public static void main(String argv[]){

/* This block is entirely for your hands

if u want to fight  against manual scavenging wake up the government by protesting against government and public [fightAgainstGoverment()]


                    (or)


else if u dont want to do make the manualscavengers to wake up and fight [fightAgainstGoverment]



                     (or)

else  wake them up to clean your streets by making instances of them and waking doyourwork() up as usual;

*/


}




Kakkos is a documentary film on manual scavengers directed by a young lady Divya from Tamilnadu
The below is a song from the documentary



Some other Tedx documentary on manual scavenging in India.