SlideShare a Scribd company logo
MineSweeper.java
public class MS {
public static void main(String[] args) {
Gamegm= new Game();
}
}
--> Game.java
public class Game {
private Bd bd;
boolean fnsh = false;
boolean w = false;
int tn=0;
public jg(){
bd = new Bd();
Py(bd);
}
public void Py(Bd bd){
do{
tn++;
System.out.println("Turn "+tn);
bd.show();
fnsh = bd.setPosition();
if(!fnsh){
bd.openNeighbors();
fnsh = bd.w();
}
}while(!fnsh);
if(bd.w()){
System.out.println("Congratulations, you let the 10 fields with the mns in "+tn+" tns");
bd.showMines();
} else {
System.out.println("Mine! You lost!");
bd.showMines();
}
}
}
--> Bd.java
import java.util.Rnm;
import java.util.Scanner;
public class Bd {
private int[][] mns;
private char[][] bdgame;
private int Line, Clm;
Rnm rnm = new Rnm();
Scanner input = new Scanner(System.in);
public Bd (){
mns = new int[10][10];
bdgame = new char[10][10];
stMs();
rnmMines();
fillTips();
startBd();
}
public boolean w(){
int ct=0;
for(int line = 1 ; line < 9 ; line++)
for(int clm = 1 ; clm < 9 ; clm++)
if(bdgame[line][clm]=='_')
ct++;
if(ct == 10)
return true;
else
return false;
}
public void oN(){
for(int i=-1 ; i<2 ; i++)
for(int j=-1 ; j<2 ; j++)
if( (mns[Ln+i][Clm+j] != -1) && (Ln != 0 && Ln != 9 && Clm != 0 && Clm != 9) )
bdgame[Ln+i][Clm+j]=Character.forDigit(mns[Ln+i][Clm+j], 10);
}
public int getPosition(int Ln, int Clm){
retn mns[Ln][Clm];
}
public boolean setPosition(){
do{
System.out.print(" Ln: ");
Ln = input.nextInt();
System.out.print("Clm: ");
Clm = input.nextInt();
if( (bdgame[Ln][Clm] != '_') && ((Ln < 9 && Ln > 0) && (Clm < 9 && Clm > 0)))
System.out.println("Field already shown");
if( Ln < 1 || Ln > 8 || Clm < 1 || Clm > 8)
System.out.println("Choose a number between 1 and 8");
}while((Ln < 1 || Ln > 8 || Clm < 1 || Clm > 8) || (bdgame[Ln][Clm] != '_') );
if(getPosition(Ln, Clm)== -1)
retn true;
else
retn false;
}
public void show(){
System.out.println(" Lns");
for(int Ln = 8 ; Ln > 0 ; Ln--){
System.out.print(" "+Ln + " ");
for(int Clm = 1 ; Clm < 9 ; Clm++){
System.out.print(" "+ bdgame[Ln][Clm]);
}
System.out.println();
}
System.out.println(" 1 2 3 4 5 6 7 8");
System.out.println(" Clms");
}
public void fillTips(){
for(int ln=1 ; ln < 9 ; ln++)
for(int clm=1 ; clm < 9 ; clm++){
for(int i=-1 ; i<=1 ; i++)
for(int j=-1 ; j<=1 ; j++)
if(mns[ln][clm] != -1)
if(mns[ln+i][clm+j] == -1)
mns[ln][clm]++;
}
}
public void showMines(){
for(int i=1 ; i < 9; i++)
for(int j=1 ; j < 9 ; j++)
if(mns[i][j] == -1)
bdgame[i][j]='*';
show();
}
public void startBd(){
for(int i=1 ; i
Solution
MineSweeper.java
public class MS {
public static void main(String[] args) {
Gamegm= new Game();
}
}
--> Game.java
public class Game {
private Bd bd;
boolean fnsh = false;
boolean w = false;
int tn=0;
public jg(){
bd = new Bd();
Py(bd);
}
public void Py(Bd bd){
do{
tn++;
System.out.println("Turn "+tn);
bd.show();
fnsh = bd.setPosition();
if(!fnsh){
bd.openNeighbors();
fnsh = bd.w();
}
}while(!fnsh);
if(bd.w()){
System.out.println("Congratulations, you let the 10 fields with the mns in "+tn+" tns");
bd.showMines();
} else {
System.out.println("Mine! You lost!");
bd.showMines();
}
}
}
--> Bd.java
import java.util.Rnm;
import java.util.Scanner;
public class Bd {
private int[][] mns;
private char[][] bdgame;
private int Line, Clm;
Rnm rnm = new Rnm();
Scanner input = new Scanner(System.in);
public Bd (){
mns = new int[10][10];
bdgame = new char[10][10];
stMs();
rnmMines();
fillTips();
startBd();
}
public boolean w(){
int ct=0;
for(int line = 1 ; line < 9 ; line++)
for(int clm = 1 ; clm < 9 ; clm++)
if(bdgame[line][clm]=='_')
ct++;
if(ct == 10)
return true;
else
return false;
}
public void oN(){
for(int i=-1 ; i<2 ; i++)
for(int j=-1 ; j<2 ; j++)
if( (mns[Ln+i][Clm+j] != -1) && (Ln != 0 && Ln != 9 && Clm != 0 && Clm != 9) )
bdgame[Ln+i][Clm+j]=Character.forDigit(mns[Ln+i][Clm+j], 10);
}
public int getPosition(int Ln, int Clm){
retn mns[Ln][Clm];
}
public boolean setPosition(){
do{
System.out.print(" Ln: ");
Ln = input.nextInt();
System.out.print("Clm: ");
Clm = input.nextInt();
if( (bdgame[Ln][Clm] != '_') && ((Ln < 9 && Ln > 0) && (Clm < 9 && Clm > 0)))
System.out.println("Field already shown");
if( Ln < 1 || Ln > 8 || Clm < 1 || Clm > 8)
System.out.println("Choose a number between 1 and 8");
}while((Ln < 1 || Ln > 8 || Clm < 1 || Clm > 8) || (bdgame[Ln][Clm] != '_') );
if(getPosition(Ln, Clm)== -1)
retn true;
else
retn false;
}
public void show(){
System.out.println(" Lns");
for(int Ln = 8 ; Ln > 0 ; Ln--){
System.out.print(" "+Ln + " ");
for(int Clm = 1 ; Clm < 9 ; Clm++){
System.out.print(" "+ bdgame[Ln][Clm]);
}
System.out.println();
}
System.out.println(" 1 2 3 4 5 6 7 8");
System.out.println(" Clms");
}
public void fillTips(){
for(int ln=1 ; ln < 9 ; ln++)
for(int clm=1 ; clm < 9 ; clm++){
for(int i=-1 ; i<=1 ; i++)
for(int j=-1 ; j<=1 ; j++)
if(mns[ln][clm] != -1)
if(mns[ln+i][clm+j] == -1)
mns[ln][clm]++;
}
}
public void showMines(){
for(int i=1 ; i < 9; i++)
for(int j=1 ; j < 9 ; j++)
if(mns[i][j] == -1)
bdgame[i][j]='*';
show();
}
public void startBd(){
for(int i=1 ; i

More Related Content

Similar to MineSweeper.java public class MS { public static void main(Strin.pdf

QA Auotmation Java programs,theory
QA Auotmation Java programs,theory QA Auotmation Java programs,theory
QA Auotmation Java programs,theory
archana singh
 
package Assignment;import java.util.;public class assignment .pdf
package Assignment;import java.util.;public class assignment .pdfpackage Assignment;import java.util.;public class assignment .pdf
package Assignment;import java.util.;public class assignment .pdf
noelbuddy
 
Utility Classes Are Killing Us
Utility Classes Are Killing UsUtility Classes Are Killing Us
Utility Classes Are Killing Us
Yegor Bugayenko
 
Project_Euler_No_104_Pandigital_Fibonacci_ends
Project_Euler_No_104_Pandigital_Fibonacci_endsProject_Euler_No_104_Pandigital_Fibonacci_ends
Project_Euler_No_104_Pandigital_Fibonacci_ends? ?
 
81818088 isc-class-xii-computer-science-project-java-programs
81818088 isc-class-xii-computer-science-project-java-programs81818088 isc-class-xii-computer-science-project-java-programs
81818088 isc-class-xii-computer-science-project-java-programsAbhishek Jena
 
Java Programpublic class Fraction {   instance variablesin.pdf
Java Programpublic class Fraction {   instance variablesin.pdfJava Programpublic class Fraction {   instance variablesin.pdf
Java Programpublic class Fraction {   instance variablesin.pdf
aroramobiles1
 
Sharable_Java_Python.pdf
Sharable_Java_Python.pdfSharable_Java_Python.pdf
Sharable_Java_Python.pdf
ICADCMLTPC
 
public interface Game Note interface in place of class { .pdf
public interface Game  Note interface in place of class { .pdfpublic interface Game  Note interface in place of class { .pdf
public interface Game Note interface in place of class { .pdf
kavithaarp
 
Team public class Team {    private String teamId;    priva.pdf
Team public class Team {    private String teamId;    priva.pdfTeam public class Team {    private String teamId;    priva.pdf
Team public class Team {    private String teamId;    priva.pdf
DEEPAKSONI562
 
.net progrmming part2
.net progrmming part2.net progrmming part2
.net progrmming part2
Dr.M.Karthika parthasarathy
 
import java.util.Scanner;public class Main {private static i.pdf
import java.util.Scanner;public class Main {private static i.pdfimport java.util.Scanner;public class Main {private static i.pdf
import java.util.Scanner;public class Main {private static i.pdf
stopgolook
 
VTU Data Structures Lab Manual
VTU Data Structures Lab ManualVTU Data Structures Lab Manual
VTU Data Structures Lab Manual
Nithin Kumar,VVCE, Mysuru
 
You will write a multi-interface version of the well-known concentra.pdf
You will write a multi-interface version of the well-known concentra.pdfYou will write a multi-interface version of the well-known concentra.pdf
You will write a multi-interface version of the well-known concentra.pdf
FashionColZone
 
Example of JAVA Program
Example of JAVA ProgramExample of JAVA Program
Example of JAVA ProgramTrenton Asbury
 
.net progrmming part1
.net progrmming part1.net progrmming part1
.net progrmming part1
Dr.M.Karthika parthasarathy
 
Complier File
Complier FileComplier File
Complier File
Garima Singh
 
ch04-conditional-execution.ppt
ch04-conditional-execution.pptch04-conditional-execution.ppt
ch04-conditional-execution.ppt
Mahyuddin8
 
The following code, is a one player battleship game in JAVA. Im tryi.pdf
The following code, is a one player battleship game in JAVA. Im tryi.pdfThe following code, is a one player battleship game in JAVA. Im tryi.pdf
The following code, is a one player battleship game in JAVA. Im tryi.pdf
fonecomp
 
ch05-program-logic-indefinite-loops.ppt
ch05-program-logic-indefinite-loops.pptch05-program-logic-indefinite-loops.ppt
ch05-program-logic-indefinite-loops.ppt
Mahyuddin8
 

Similar to MineSweeper.java public class MS { public static void main(Strin.pdf (20)

QA Auotmation Java programs,theory
QA Auotmation Java programs,theory QA Auotmation Java programs,theory
QA Auotmation Java programs,theory
 
package Assignment;import java.util.;public class assignment .pdf
package Assignment;import java.util.;public class assignment .pdfpackage Assignment;import java.util.;public class assignment .pdf
package Assignment;import java.util.;public class assignment .pdf
 
Utility Classes Are Killing Us
Utility Classes Are Killing UsUtility Classes Are Killing Us
Utility Classes Are Killing Us
 
Sam wd programs
Sam wd programsSam wd programs
Sam wd programs
 
Project_Euler_No_104_Pandigital_Fibonacci_ends
Project_Euler_No_104_Pandigital_Fibonacci_endsProject_Euler_No_104_Pandigital_Fibonacci_ends
Project_Euler_No_104_Pandigital_Fibonacci_ends
 
81818088 isc-class-xii-computer-science-project-java-programs
81818088 isc-class-xii-computer-science-project-java-programs81818088 isc-class-xii-computer-science-project-java-programs
81818088 isc-class-xii-computer-science-project-java-programs
 
Java Programpublic class Fraction {   instance variablesin.pdf
Java Programpublic class Fraction {   instance variablesin.pdfJava Programpublic class Fraction {   instance variablesin.pdf
Java Programpublic class Fraction {   instance variablesin.pdf
 
Sharable_Java_Python.pdf
Sharable_Java_Python.pdfSharable_Java_Python.pdf
Sharable_Java_Python.pdf
 
public interface Game Note interface in place of class { .pdf
public interface Game  Note interface in place of class { .pdfpublic interface Game  Note interface in place of class { .pdf
public interface Game Note interface in place of class { .pdf
 
Team public class Team {    private String teamId;    priva.pdf
Team public class Team {    private String teamId;    priva.pdfTeam public class Team {    private String teamId;    priva.pdf
Team public class Team {    private String teamId;    priva.pdf
 
.net progrmming part2
.net progrmming part2.net progrmming part2
.net progrmming part2
 
import java.util.Scanner;public class Main {private static i.pdf
import java.util.Scanner;public class Main {private static i.pdfimport java.util.Scanner;public class Main {private static i.pdf
import java.util.Scanner;public class Main {private static i.pdf
 
VTU Data Structures Lab Manual
VTU Data Structures Lab ManualVTU Data Structures Lab Manual
VTU Data Structures Lab Manual
 
You will write a multi-interface version of the well-known concentra.pdf
You will write a multi-interface version of the well-known concentra.pdfYou will write a multi-interface version of the well-known concentra.pdf
You will write a multi-interface version of the well-known concentra.pdf
 
Example of JAVA Program
Example of JAVA ProgramExample of JAVA Program
Example of JAVA Program
 
.net progrmming part1
.net progrmming part1.net progrmming part1
.net progrmming part1
 
Complier File
Complier FileComplier File
Complier File
 
ch04-conditional-execution.ppt
ch04-conditional-execution.pptch04-conditional-execution.ppt
ch04-conditional-execution.ppt
 
The following code, is a one player battleship game in JAVA. Im tryi.pdf
The following code, is a one player battleship game in JAVA. Im tryi.pdfThe following code, is a one player battleship game in JAVA. Im tryi.pdf
The following code, is a one player battleship game in JAVA. Im tryi.pdf
 
ch05-program-logic-indefinite-loops.ppt
ch05-program-logic-indefinite-loops.pptch05-program-logic-indefinite-loops.ppt
ch05-program-logic-indefinite-loops.ppt
 

More from aniyathikitchen

1) (i)Finance (H)(ii) Corporation (J)(iii) Treasurer (G)(iv) L.pdf
1) (i)Finance (H)(ii) Corporation (J)(iii) Treasurer (G)(iv) L.pdf1) (i)Finance (H)(ii) Corporation (J)(iii) Treasurer (G)(iv) L.pdf
1) (i)Finance (H)(ii) Corporation (J)(iii) Treasurer (G)(iv) L.pdf
aniyathikitchen
 
let no, na,nw be the refractive indices of oil, air and waterrespec.pdf
 let no, na,nw be the refractive indices of oil, air and waterrespec.pdf let no, na,nw be the refractive indices of oil, air and waterrespec.pdf
let no, na,nw be the refractive indices of oil, air and waterrespec.pdf
aniyathikitchen
 
sol Quantum numbers describe an electrons shell.pdf
                     sol Quantum numbers describe an electrons shell.pdf                     sol Quantum numbers describe an electrons shell.pdf
sol Quantum numbers describe an electrons shell.pdf
aniyathikitchen
 
There should be a table in your book with these L.pdf
                     There should be a table in your book with these L.pdf                     There should be a table in your book with these L.pdf
There should be a table in your book with these L.pdf
aniyathikitchen
 
single displacement occurs when an element takes .pdf
                     single displacement occurs when an element takes .pdf                     single displacement occurs when an element takes .pdf
single displacement occurs when an element takes .pdf
aniyathikitchen
 
pH Electrode Maintenance The entire glass membra.pdf
                     pH Electrode Maintenance  The entire glass membra.pdf                     pH Electrode Maintenance  The entire glass membra.pdf
pH Electrode Maintenance The entire glass membra.pdf
aniyathikitchen
 
O-O+ +e- is the correct answer as first ionizati.pdf
                     O-O+ +e- is the correct answer as first ionizati.pdf                     O-O+ +e- is the correct answer as first ionizati.pdf
O-O+ +e- is the correct answer as first ionizati.pdf
aniyathikitchen
 
O and H always make covalent bond. You can tell .pdf
                     O and H always make covalent bond.  You can tell .pdf                     O and H always make covalent bond.  You can tell .pdf
O and H always make covalent bond. You can tell .pdf
aniyathikitchen
 
NiCO3 (s) + H2SO4 (aq) NiSO4 (s) + CO2 (g) + H2.pdf
                     NiCO3 (s) + H2SO4 (aq)  NiSO4 (s) + CO2 (g) + H2.pdf                     NiCO3 (s) + H2SO4 (aq)  NiSO4 (s) + CO2 (g) + H2.pdf
NiCO3 (s) + H2SO4 (aq) NiSO4 (s) + CO2 (g) + H2.pdf
aniyathikitchen
 
When I was getting ready at home, I was excited and anxious, but as .pdf
When I was getting ready at home, I was excited and anxious, but as .pdfWhen I was getting ready at home, I was excited and anxious, but as .pdf
When I was getting ready at home, I was excited and anxious, but as .pdf
aniyathikitchen
 
Viruses are those biological entities which are intermediate between.pdf
Viruses are those biological entities which are intermediate between.pdfViruses are those biological entities which are intermediate between.pdf
Viruses are those biological entities which are intermediate between.pdf
aniyathikitchen
 
The most probable answer if this question seems to be option B. The .pdf
The most probable answer if this question seems to be option B. The .pdfThe most probable answer if this question seems to be option B. The .pdf
The most probable answer if this question seems to be option B. The .pdf
aniyathikitchen
 
Exactly how you have drawn it, this compounds I.pdf
                     Exactly how you have drawn it, this compounds I.pdf                     Exactly how you have drawn it, this compounds I.pdf
Exactly how you have drawn it, this compounds I.pdf
aniyathikitchen
 
The contamination could be due to the presence of yeast in the cultu.pdf
The contamination could be due to the presence of yeast in the cultu.pdfThe contamination could be due to the presence of yeast in the cultu.pdf
The contamination could be due to the presence of yeast in the cultu.pdf
aniyathikitchen
 
Systems Development Life Cycle(SDLC) is the step by step process whi.pdf
Systems Development Life Cycle(SDLC) is the step by step process whi.pdfSystems Development Life Cycle(SDLC) is the step by step process whi.pdf
Systems Development Life Cycle(SDLC) is the step by step process whi.pdf
aniyathikitchen
 
d. spontaneous at all temperatures .pdf
                     d. spontaneous at all temperatures               .pdf                     d. spontaneous at all temperatures               .pdf
d. spontaneous at all temperatures .pdf
aniyathikitchen
 
It is truebecause The SMTP server cannot find the destination emai.pdf
It is truebecause The SMTP server cannot find the destination emai.pdfIt is truebecause The SMTP server cannot find the destination emai.pdf
It is truebecause The SMTP server cannot find the destination emai.pdf
aniyathikitchen
 
Homo neanderthalensis are evolved and lived ina) Europe andor sou.pdf
Homo neanderthalensis are evolved and lived ina) Europe andor sou.pdfHomo neanderthalensis are evolved and lived ina) Europe andor sou.pdf
Homo neanderthalensis are evolved and lived ina) Europe andor sou.pdf
aniyathikitchen
 
B. note aldehydes hydrolysis gives diol products.pdf
                     B. note aldehydes hydrolysis gives diol products.pdf                     B. note aldehydes hydrolysis gives diol products.pdf
B. note aldehydes hydrolysis gives diol products.pdf
aniyathikitchen
 
Hi,I have updated your code. It is working fine now. Highllighted .pdf
Hi,I have updated your code. It is working fine now. Highllighted .pdfHi,I have updated your code. It is working fine now. Highllighted .pdf
Hi,I have updated your code. It is working fine now. Highllighted .pdf
aniyathikitchen
 

More from aniyathikitchen (20)

1) (i)Finance (H)(ii) Corporation (J)(iii) Treasurer (G)(iv) L.pdf
1) (i)Finance (H)(ii) Corporation (J)(iii) Treasurer (G)(iv) L.pdf1) (i)Finance (H)(ii) Corporation (J)(iii) Treasurer (G)(iv) L.pdf
1) (i)Finance (H)(ii) Corporation (J)(iii) Treasurer (G)(iv) L.pdf
 
let no, na,nw be the refractive indices of oil, air and waterrespec.pdf
 let no, na,nw be the refractive indices of oil, air and waterrespec.pdf let no, na,nw be the refractive indices of oil, air and waterrespec.pdf
let no, na,nw be the refractive indices of oil, air and waterrespec.pdf
 
sol Quantum numbers describe an electrons shell.pdf
                     sol Quantum numbers describe an electrons shell.pdf                     sol Quantum numbers describe an electrons shell.pdf
sol Quantum numbers describe an electrons shell.pdf
 
There should be a table in your book with these L.pdf
                     There should be a table in your book with these L.pdf                     There should be a table in your book with these L.pdf
There should be a table in your book with these L.pdf
 
single displacement occurs when an element takes .pdf
                     single displacement occurs when an element takes .pdf                     single displacement occurs when an element takes .pdf
single displacement occurs when an element takes .pdf
 
pH Electrode Maintenance The entire glass membra.pdf
                     pH Electrode Maintenance  The entire glass membra.pdf                     pH Electrode Maintenance  The entire glass membra.pdf
pH Electrode Maintenance The entire glass membra.pdf
 
O-O+ +e- is the correct answer as first ionizati.pdf
                     O-O+ +e- is the correct answer as first ionizati.pdf                     O-O+ +e- is the correct answer as first ionizati.pdf
O-O+ +e- is the correct answer as first ionizati.pdf
 
O and H always make covalent bond. You can tell .pdf
                     O and H always make covalent bond.  You can tell .pdf                     O and H always make covalent bond.  You can tell .pdf
O and H always make covalent bond. You can tell .pdf
 
NiCO3 (s) + H2SO4 (aq) NiSO4 (s) + CO2 (g) + H2.pdf
                     NiCO3 (s) + H2SO4 (aq)  NiSO4 (s) + CO2 (g) + H2.pdf                     NiCO3 (s) + H2SO4 (aq)  NiSO4 (s) + CO2 (g) + H2.pdf
NiCO3 (s) + H2SO4 (aq) NiSO4 (s) + CO2 (g) + H2.pdf
 
When I was getting ready at home, I was excited and anxious, but as .pdf
When I was getting ready at home, I was excited and anxious, but as .pdfWhen I was getting ready at home, I was excited and anxious, but as .pdf
When I was getting ready at home, I was excited and anxious, but as .pdf
 
Viruses are those biological entities which are intermediate between.pdf
Viruses are those biological entities which are intermediate between.pdfViruses are those biological entities which are intermediate between.pdf
Viruses are those biological entities which are intermediate between.pdf
 
The most probable answer if this question seems to be option B. The .pdf
The most probable answer if this question seems to be option B. The .pdfThe most probable answer if this question seems to be option B. The .pdf
The most probable answer if this question seems to be option B. The .pdf
 
Exactly how you have drawn it, this compounds I.pdf
                     Exactly how you have drawn it, this compounds I.pdf                     Exactly how you have drawn it, this compounds I.pdf
Exactly how you have drawn it, this compounds I.pdf
 
The contamination could be due to the presence of yeast in the cultu.pdf
The contamination could be due to the presence of yeast in the cultu.pdfThe contamination could be due to the presence of yeast in the cultu.pdf
The contamination could be due to the presence of yeast in the cultu.pdf
 
Systems Development Life Cycle(SDLC) is the step by step process whi.pdf
Systems Development Life Cycle(SDLC) is the step by step process whi.pdfSystems Development Life Cycle(SDLC) is the step by step process whi.pdf
Systems Development Life Cycle(SDLC) is the step by step process whi.pdf
 
d. spontaneous at all temperatures .pdf
                     d. spontaneous at all temperatures               .pdf                     d. spontaneous at all temperatures               .pdf
d. spontaneous at all temperatures .pdf
 
It is truebecause The SMTP server cannot find the destination emai.pdf
It is truebecause The SMTP server cannot find the destination emai.pdfIt is truebecause The SMTP server cannot find the destination emai.pdf
It is truebecause The SMTP server cannot find the destination emai.pdf
 
Homo neanderthalensis are evolved and lived ina) Europe andor sou.pdf
Homo neanderthalensis are evolved and lived ina) Europe andor sou.pdfHomo neanderthalensis are evolved and lived ina) Europe andor sou.pdf
Homo neanderthalensis are evolved and lived ina) Europe andor sou.pdf
 
B. note aldehydes hydrolysis gives diol products.pdf
                     B. note aldehydes hydrolysis gives diol products.pdf                     B. note aldehydes hydrolysis gives diol products.pdf
B. note aldehydes hydrolysis gives diol products.pdf
 
Hi,I have updated your code. It is working fine now. Highllighted .pdf
Hi,I have updated your code. It is working fine now. Highllighted .pdfHi,I have updated your code. It is working fine now. Highllighted .pdf
Hi,I have updated your code. It is working fine now. Highllighted .pdf
 

Recently uploaded

Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
Mohammed Sikander
 
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdfMASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
goswamiyash170123
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
Marketing internship report file for MBA
Marketing internship report file for MBAMarketing internship report file for MBA
Marketing internship report file for MBA
gb193092
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
thanhdowork
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 
Chapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdfChapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdf
Kartik Tiwari
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 

Recently uploaded (20)

Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
 
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdfMASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
Marketing internship report file for MBA
Marketing internship report file for MBAMarketing internship report file for MBA
Marketing internship report file for MBA
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 
Chapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdfChapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdf
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 

MineSweeper.java public class MS { public static void main(Strin.pdf

  • 1. MineSweeper.java public class MS { public static void main(String[] args) { Gamegm= new Game(); } } --> Game.java public class Game { private Bd bd; boolean fnsh = false; boolean w = false; int tn=0; public jg(){ bd = new Bd(); Py(bd); } public void Py(Bd bd){ do{ tn++; System.out.println("Turn "+tn); bd.show(); fnsh = bd.setPosition(); if(!fnsh){ bd.openNeighbors(); fnsh = bd.w(); } }while(!fnsh); if(bd.w()){ System.out.println("Congratulations, you let the 10 fields with the mns in "+tn+" tns"); bd.showMines();
  • 2. } else { System.out.println("Mine! You lost!"); bd.showMines(); } } } --> Bd.java import java.util.Rnm; import java.util.Scanner; public class Bd { private int[][] mns; private char[][] bdgame; private int Line, Clm; Rnm rnm = new Rnm(); Scanner input = new Scanner(System.in); public Bd (){ mns = new int[10][10]; bdgame = new char[10][10]; stMs(); rnmMines(); fillTips(); startBd(); } public boolean w(){ int ct=0; for(int line = 1 ; line < 9 ; line++) for(int clm = 1 ; clm < 9 ; clm++) if(bdgame[line][clm]=='_') ct++; if(ct == 10) return true; else return false;
  • 3. } public void oN(){ for(int i=-1 ; i<2 ; i++) for(int j=-1 ; j<2 ; j++) if( (mns[Ln+i][Clm+j] != -1) && (Ln != 0 && Ln != 9 && Clm != 0 && Clm != 9) ) bdgame[Ln+i][Clm+j]=Character.forDigit(mns[Ln+i][Clm+j], 10); } public int getPosition(int Ln, int Clm){ retn mns[Ln][Clm]; } public boolean setPosition(){ do{ System.out.print(" Ln: "); Ln = input.nextInt(); System.out.print("Clm: "); Clm = input.nextInt(); if( (bdgame[Ln][Clm] != '_') && ((Ln < 9 && Ln > 0) && (Clm < 9 && Clm > 0))) System.out.println("Field already shown"); if( Ln < 1 || Ln > 8 || Clm < 1 || Clm > 8) System.out.println("Choose a number between 1 and 8"); }while((Ln < 1 || Ln > 8 || Clm < 1 || Clm > 8) || (bdgame[Ln][Clm] != '_') ); if(getPosition(Ln, Clm)== -1) retn true; else retn false; }
  • 4. public void show(){ System.out.println(" Lns"); for(int Ln = 8 ; Ln > 0 ; Ln--){ System.out.print(" "+Ln + " "); for(int Clm = 1 ; Clm < 9 ; Clm++){ System.out.print(" "+ bdgame[Ln][Clm]); } System.out.println(); } System.out.println(" 1 2 3 4 5 6 7 8"); System.out.println(" Clms"); } public void fillTips(){ for(int ln=1 ; ln < 9 ; ln++) for(int clm=1 ; clm < 9 ; clm++){ for(int i=-1 ; i<=1 ; i++) for(int j=-1 ; j<=1 ; j++) if(mns[ln][clm] != -1) if(mns[ln+i][clm+j] == -1) mns[ln][clm]++; } } public void showMines(){ for(int i=1 ; i < 9; i++) for(int j=1 ; j < 9 ; j++) if(mns[i][j] == -1)
  • 5. bdgame[i][j]='*'; show(); } public void startBd(){ for(int i=1 ; i Solution MineSweeper.java public class MS { public static void main(String[] args) { Gamegm= new Game(); } } --> Game.java public class Game { private Bd bd; boolean fnsh = false; boolean w = false; int tn=0; public jg(){ bd = new Bd(); Py(bd); } public void Py(Bd bd){ do{ tn++; System.out.println("Turn "+tn); bd.show(); fnsh = bd.setPosition(); if(!fnsh){ bd.openNeighbors();
  • 6. fnsh = bd.w(); } }while(!fnsh); if(bd.w()){ System.out.println("Congratulations, you let the 10 fields with the mns in "+tn+" tns"); bd.showMines(); } else { System.out.println("Mine! You lost!"); bd.showMines(); } } } --> Bd.java import java.util.Rnm; import java.util.Scanner; public class Bd { private int[][] mns; private char[][] bdgame; private int Line, Clm; Rnm rnm = new Rnm(); Scanner input = new Scanner(System.in); public Bd (){ mns = new int[10][10]; bdgame = new char[10][10]; stMs(); rnmMines(); fillTips(); startBd(); } public boolean w(){ int ct=0;
  • 7. for(int line = 1 ; line < 9 ; line++) for(int clm = 1 ; clm < 9 ; clm++) if(bdgame[line][clm]=='_') ct++; if(ct == 10) return true; else return false; } public void oN(){ for(int i=-1 ; i<2 ; i++) for(int j=-1 ; j<2 ; j++) if( (mns[Ln+i][Clm+j] != -1) && (Ln != 0 && Ln != 9 && Clm != 0 && Clm != 9) ) bdgame[Ln+i][Clm+j]=Character.forDigit(mns[Ln+i][Clm+j], 10); } public int getPosition(int Ln, int Clm){ retn mns[Ln][Clm]; } public boolean setPosition(){ do{ System.out.print(" Ln: "); Ln = input.nextInt(); System.out.print("Clm: "); Clm = input.nextInt(); if( (bdgame[Ln][Clm] != '_') && ((Ln < 9 && Ln > 0) && (Clm < 9 && Clm > 0))) System.out.println("Field already shown"); if( Ln < 1 || Ln > 8 || Clm < 1 || Clm > 8) System.out.println("Choose a number between 1 and 8");
  • 8. }while((Ln < 1 || Ln > 8 || Clm < 1 || Clm > 8) || (bdgame[Ln][Clm] != '_') ); if(getPosition(Ln, Clm)== -1) retn true; else retn false; } public void show(){ System.out.println(" Lns"); for(int Ln = 8 ; Ln > 0 ; Ln--){ System.out.print(" "+Ln + " "); for(int Clm = 1 ; Clm < 9 ; Clm++){ System.out.print(" "+ bdgame[Ln][Clm]); } System.out.println(); } System.out.println(" 1 2 3 4 5 6 7 8"); System.out.println(" Clms"); } public void fillTips(){ for(int ln=1 ; ln < 9 ; ln++) for(int clm=1 ; clm < 9 ; clm++){ for(int i=-1 ; i<=1 ; i++) for(int j=-1 ; j<=1 ; j++) if(mns[ln][clm] != -1) if(mns[ln+i][clm+j] == -1) mns[ln][clm]++;
  • 9. } } public void showMines(){ for(int i=1 ; i < 9; i++) for(int j=1 ; j < 9 ; j++) if(mns[i][j] == -1) bdgame[i][j]='*'; show(); } public void startBd(){ for(int i=1 ; i