# HW1 Issues / Spec Clarification / FAQ / Notes
We will continuously organize all the issues, questions (from students) and the clarifications, notes (from us) in this document. Thanks to those who are willing to make this a better homework.
## Issues
1. Can't run `test.sh` successfully
You may encounter an error when you sun `test.sh`, that says: `Exception in thread "main" java.lang.NoClassDefFoundError: Main`
This tells you that `TestSuite` can't compile since it can't find the `Main` class.
Solution: Modify a line in the `test.sh` where it starts with `javac` to
`javac -cp . TestSuite.java -d ../out/`
> Note that we add a class-path by a dot (`-cp .`), which means to include all the classes in the directory where the compilation is performed.
## Hw1's Spec Clarification
As there may be some uncertainties about our spec's Input and Output, this section provides the clarficiation officially.
1.
>"I could not identify whether or not should I add a period to the end of the line, nor is it clearly stated. Usually, an ellipsis consists of 3 dots and perhaps another dot should be appended?"
`Player <player’s name> plays a <card pattern> <suit>[<rank>] <suit>[<rank>] ...`
--> **Yes, you should add a period to the end of that line.**
For example: `Player Chaoyu plays a pair C[8] D[8].`
In this output line, no matter what the card pattern is, there is always a period directly following the last card.
## FAQ
Q: 想請問作業中有關出牌的不合法輸入,會包含超出範圍的數字嗎?例如,手牌只有4張(編號0到3),會有使用者輸入8或輸入-2之類的狀況嗎,又會是摻雜-1在牌組中 (ex. 0 1 -1 3 2)的情況。
A: The choice-of-cards indices are guaranteed to **be in 0 to n-1** (given you have n hand-cards) and **distinct**.
---
Q: "Based on my understanding, one player can't do any action in a certain round after he/she passed. However, I found out in some test cases, some players are able to pass even if they passed before.
**My question is, is it guaranteed that, after someone passed, can he/she play any cards later in this round**?
If not, how do we determine if a round ends?"
A: Yes.
Our spec doesn't say that in the same round a player can't perform any actions after he has passed.
**Every player can either pass or play a legal card pattern in every turn for sure.**
(Only in one situation that you can't pass. that is, "You can’t pass in the new round." if the player is at the beginning of the round.)
However, **three consecutive passes end the current round.
This is the only point how you determine if the current round should be ended.**
---
Q: 我研究了一段時間還是不確定 `-sourcepath` 這個參數對我們繳交作業上有何影響 我自己一直用這個參數也是編譯不過的
A: It's guaranteed that if you put all of your java files under the *src* directory and launch your Big2 game from your *Main* class
(Main class must be directly under the src directory), then your code should work fine for us to judge.
`javac -sourcepath src/ -d out/ src/TestSuite.java`
Running this command from your project directory should work.
where `src/TestSuite.java` specifies the target files to compile (or src/*.java if multiple) (this will also include the other source files for resolving dependencies)
`-d out` specifies where the compiled artifact should be placed and
`-sourcepath src/` specifies the source root directory of the compiled source files.
---
Q: I found out that there is some inconsistency in the format of some test cases provided on GitHub. For example, "always-play-first-card.out" is ended with **'\n'**, while "fullhouse.out" is not.
A: The differences in the **trailing whitespace (spaces, tabs, line-breaks) in each line will be tolerated** while judging your code. You can verify this by running the test.sh script.
---
Q: 從作業pdf的Game Flow中可以看到第一位玩家必須在第一個回合出梅花三,可是在Output Format中沒有說如果玩家違反這個規則要輸出甚麼錯誤訊息。
A: In this case, you should print "Invalid play, please try again."
## Notes
This section lists some notes regarding your HW1's implementation.
1. How to access or parse the input (from `System.in`) in our program properly?
I recommend to do the followings or you may encounter issues (e.g., `java.util.NoSuchElementException` thrown during `Scanner`'s `nextInt()` or `nextLine()`) when you run the test case.
First, create a public class `Inputs` (or any name you like) in a package `utils` (or any name you like) under the `src` directory.
Second, the `Inputs` class's content:
```java=
public class Inputs {
public final static Scanner in = new Scanner(System.in);
}
```
**Then, use `Inputs.in` thourghout your program to read from the standard in.**
Like this:
```java=
int action = Inputs.in.nextInt();
...
String line = Inputs.in.nextLine();
...
```
or this, with the help of [static import](https://www.geeksforgeeks.org/static-import-java/)
```java=
import static utils.Inputs.in;
...
int action = in.nextInt();
...
String line = in.nextLine();
...
```
If you don't use the **same *Scanner* instance** throughout your program, there might be some input problems due to the I/O buffering issues.
---
If all of the above can't solve your problems, please contact `foop_ta@csie.ntu.edu.tw`.