diff --git a/.idea/misc.xml b/.idea/misc.xml
index 4894101..147bde9 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -3,7 +3,7 @@
-
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..35eb1dd
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/README.md b/README.md
index e759bf3..c0eeb73 100644
--- a/README.md
+++ b/README.md
@@ -16,7 +16,7 @@
* Is the **blank** object mutable or immutable? How can you tell?
```text
-PUT ANSWER TO #2 HERE
+It is mutable
```
```java
@@ -47,7 +47,7 @@ public class Puzzler {
* Explain how the return values from #3 and #4 differ.
```text
-PUT ANSWER TO #5 HERE
+Method 3 returns a numeric value while method 4 returns a point which represents the center of a rectangle.
```
```java
@@ -87,14 +87,16 @@ Recall that aliases are two variables that refer to the same object.
* Put the output in the text block below
```text
-PUT ANSWER TO #2 HERE
+The output of the program would be
+(5'8)
+(5'7)
```
3. At the end of main, are p1 and p2 aliased? Why or why not?
* Put your answer in the text block below
```text
-PUT ANSWER TO #3 HERE
+P 1 and P2 are not aliased, they represent different points in time and p1 and p2 are different points.
```
```java
diff --git a/src/BigIntRewrite.java b/src/BigIntRewrite.java
index 8f0dfce..fd7c5f9 100644
--- a/src/BigIntRewrite.java
+++ b/src/BigIntRewrite.java
@@ -1,5 +1,16 @@
+import java.math.BigInteger;
+public class void main(String[] args) {
public class BigIntRewrite {
- public static void main(String[] args) {
+ public static BigInteger pow(int x, int n) {
+ if (n == 0) return BigInteger.ONE;
+ BigInteger t = pow(x, n / 2);
+
+ if (n % 2 == 0) {
+ return t.multiply(t);
+ } else {
+ return t.multiply(t).multiply(BigInteger.valueOf(x));
+ }
}
}
+}
\ No newline at end of file
diff --git a/src/StringPlayground.java b/src/StringPlayground.java
index a930a71..e50e1ea 100644
--- a/src/StringPlayground.java
+++ b/src/StringPlayground.java
@@ -1,4 +1,17 @@
public class StringPlayground {
- public static void main(String[] args) {
+ public static int checkParentheses(String s, char openChar, char closeChar) {
+ int count = 0;
+ for (int i = 0; i < s.length(); i++) {
+ char c = s.charAt(i);
+ if (c == openChar) { count++; }
+ else if (c == closeChar) { count--; }
+ }
+ return count;
}
+}
+
+public static void main(String[] args) {
+ System.out.println(StringPlayground.checkParentheses("((3 + 7) * 2)"));
+ System.out.println(StringPlayground.checkParentheses("(3 + 7) * 2)"));
+ System.out.println(StringPlayground.checkParentheses("((3 + 7 * 2"));
}
\ No newline at end of file
diff --git a/src/part2_1.png b/src/part2_1.png
new file mode 100644
index 0000000..a844a40
Binary files /dev/null and b/src/part2_1.png differ
diff --git a/src/part2_2.png b/src/part2_2.png
new file mode 100644
index 0000000..57ffabf
Binary files /dev/null and b/src/part2_2.png differ
diff --git a/src/part3_1.png b/src/part3_1.png
new file mode 100644
index 0000000..9a6c6ca
Binary files /dev/null and b/src/part3_1.png differ