-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathABAndChess.java
More file actions
51 lines (41 loc) · 1.17 KB
/
ABAndChess.java
File metadata and controls
51 lines (41 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import java.util.HashMap;
import java.util.Scanner;
public class ABAndChess
{
public static void main( String[] args )
{
Scanner s = new Scanner( System.in );
HashMap<String, Integer> map = new HashMap<String, Integer>();
map.put( "Q", 9 );
map.put( "R", 5 );
map.put( "B", 3 );
map.put( "N", 3 );
map.put( "P", 1 );
map.put( "K", 0 );
map.put( ".", 0 );
int white = 0;
int black = 0;
for( int i = 0; i < 8; i++ )
{
String str = s.nextLine();
for(int j=0;j<8;j++)
{
char c =str.charAt( j );
if(c>=97 && c<=122)
{
black+= map.get( String.valueOf( c ).toUpperCase() );
}
else
{
white+=map.get( String.valueOf( c ) );
}
}
}
if(white>black)
System.out.println( "White" );
else if(white<black)
System.out.println( "Black" );
else
System.out.println( "Draw" );
}
}