Skip to content

Commit e7b3af5

Browse files
start
1 parent 7482c6d commit e7b3af5

File tree

6 files changed

+115
-0
lines changed

6 files changed

+115
-0
lines changed

pom.xml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
<packaging>jar</packaging>
7+
8+
<groupId>org.example</groupId>
9+
<artifactId>pythonchallenge</artifactId>
10+
<version>1.0.0</version>
11+
12+
<dependencies>
13+
<dependency>
14+
<groupId>junit</groupId>
15+
<artifactId>junit</artifactId>
16+
<version>4.13</version>
17+
<scope>test</scope>
18+
</dependency>
19+
</dependencies>
20+
21+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.yitianyigexiangfa.pythonchallenge;
2+
3+
import java.text.NumberFormat;
4+
5+
public class Level1 {
6+
7+
public static void main(String[] args) {
8+
Double result = Math.pow(2, 38);
9+
System.out.println(result);
10+
NumberFormat numberFormat = NumberFormat.getInstance();
11+
numberFormat.setGroupingUsed(false);
12+
String resultVal = numberFormat.format(result);
13+
System.out.println(resultVal);
14+
}
15+
16+
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.yitianyigexiangfa.pythonchallenge;
2+
3+
public class Level2 {
4+
5+
public static void main(String[] args) {
6+
char[] chars = str.toCharArray();
7+
for (char charElment: chars) {
8+
// char newChar = charElment + 2;
9+
System.out.print(Character.toString(charElment));
10+
System.out.println();
11+
int value = Character.getNumericValue(charElment);
12+
System.out.print(value);
13+
}
14+
}
15+
16+
17+
18+
private static String str = "g fmnc wms bgblr rpylqjyrc gr zw fylb. rfyrq ufyr amknsrcpq " +
19+
"ypc dmp. bmgle gr gl zw fylb gq glcddgagclr ylb rfyr'q ufw rfgq rcvr gq qm jmle. " +
20+
"sqgle qrpgle.kyicrpylq() gq pcamkkclbcb. lmu ynnjw ml rfc spj.";
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package com.yitianyigexiangfa.pythonchallenge;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package com.yitianyigexiangfa.pythonchallenge;
2+
3+
import org.junit.Test;
4+
5+
import java.text.NumberFormat;
6+
7+
import static org.junit.Assert.*;
8+
9+
public class Level1Test {
10+
11+
@Test
12+
public void pow(){
13+
Double result = Math.pow(2, 3);
14+
assertEquals(new Double(8), result);
15+
}
16+
17+
@Test
18+
public void numberFormatTest(){
19+
Double d = 123456789123D;
20+
System.out.println(d);
21+
NumberFormat numberFormat = NumberFormat.getInstance();
22+
String dStr = numberFormat.format(d);
23+
assertEquals("123,456,789,123", dStr);
24+
numberFormat.setGroupingUsed(false);
25+
String dStr2 = numberFormat.format(d);
26+
assertEquals("123456789123", dStr2);
27+
}
28+
29+
@Test
30+
public void doubleToString(){
31+
Double d = Math.pow(2, 38);
32+
System.out.println(d);
33+
NumberFormat numberFormat = NumberFormat.getInstance();
34+
numberFormat.setGroupingUsed(false);
35+
String numStr = numberFormat.format(d);
36+
System.out.println(numStr);
37+
assertEquals("2.74877906944E11", d.toString());
38+
}
39+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.yitianyigexiangfa.pythonchallenge;
2+
3+
import org.junit.Test;
4+
5+
import static org.junit.Assert.*;
6+
7+
public class Level2Test {
8+
9+
@Test
10+
public void charToInteger() {
11+
byte[] bytes = "a".getBytes();
12+
int digit = bytes[0];
13+
assertEquals(digit, 97);
14+
System.out.println(digit);
15+
}
16+
}

0 commit comments

Comments
 (0)