File tree Expand file tree Collapse file tree 2 files changed +43
-0
lines changed Expand file tree Collapse file tree 2 files changed +43
-0
lines changed Original file line number Diff line number Diff line change @@ -73,6 +73,16 @@ public static void binToDec(int binNum) {
73
73
System .out .println (dnum );
74
74
}
75
75
76
+ public static void decToBinary (int decimalNum ) {
77
+ int binNum = 0 ;
78
+ while (decimalNum > 0 ) {
79
+ int rem = decimalNum % 2 ;
80
+ binNum = (binNum * 10 ) + rem ;
81
+ decimalNum = decimalNum / 2 ;
82
+ }
83
+ System .out .println (binNum );
84
+ }
85
+
76
86
public static void main (String [] args ) {
77
87
// Scanner scanner = new Scanner(System.in);
78
88
// System.out.println("Enter side of a square");
@@ -87,5 +97,6 @@ public static void main(String[] args) {
87
97
// System.out.println(isPrime(12));
88
98
// printPrime(10);
89
99
binToDec (101 );
100
+ decToBinary (5 );
90
101
}
91
102
}
Original file line number Diff line number Diff line change
1
+ package binod .meaningful_names ;
2
+ import java .util .ArrayList ;
3
+ import java .util .List ;
4
+
5
+ public class GameBoard {
6
+
7
+ static List <Cell > gameBoard = new ArrayList <Cell >();
8
+
9
+ public static void main (String [] args ) {
10
+ List <Cell > list = getFlaggedCells ();
11
+ System .out .println (list );
12
+ }
13
+
14
+ public static List <Cell > getFlaggedCells () {
15
+ List <Cell > flaggedCells = new ArrayList <Cell >();
16
+ for (Cell cell : gameBoard )
17
+ if (cell .isFlagged ())
18
+ flaggedCells .add (cell );
19
+ return flaggedCells ;
20
+ }
21
+ }
22
+
23
+ class Cell {
24
+
25
+ int STATUS_VALUE = 0 ;
26
+
27
+ int FLAGGED = 4 ;
28
+
29
+ public boolean isFlagged () {
30
+ return STATUS_VALUE == FLAGGED ;
31
+ }
32
+ }
You can’t perform that action at this time.
0 commit comments