Skip to content
Snippets Groups Projects
Commit c98ae25b authored by qingyuw2's avatar qingyuw2
Browse files

assignment 1.2 finished

parent 8cae2c88
Branches assignment1.2
No related tags found
No related merge requests found
Showing
with 50 additions and 23 deletions
manual_test/0.png

44.1 KiB

manual_test/1.png

44.6 KiB

manual_test/2.png

43.7 KiB

manual_test/3.png

54.1 KiB

manual_test/4.png

45.9 KiB

manual_test/5.png

48.7 KiB

manual_test/6.png

43.7 KiB

# Manual Test Plan
compile and run code through terminal
```
javac startGame.java
java startGame
```
## Start Scene of the Game
Shown in 0.png. To run on your computer, please comment out all the lines except line 7.
## During the Game
Shown in 1.png, 2.png, and 3.png. To run on your computer, please comment out all the lines except line 8-line15
## Select Color After Wild Card
Shown in 4.png. To run on your computer, please comment out all the lines except line8 and line 16.
## Discard Reshuffled into Deck
Shown in 5.png. To run on your computer, please comment out all the lines except line 8 and line 17.
## End Scene of the Game
Shown in 6.png. To run on your computer, please comment out all the lines except line 8 and line 18.
\ No newline at end of file
File added
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
......@@ -5,7 +5,7 @@ import Card.Card;
import java.util.HashMap;
public class ActionCard extends Card {
// 0:skip 1:reverse 2:draw two cards 3:wild 4:wild draw four 5:switch 6:one more round
// 0:skip 1:reverse 2:draw two cards 3:wild 4:wild draw four 5:double skip 6:one more round
private int action;
private static HashMap<Integer, String> actionSet;
......@@ -16,7 +16,7 @@ public class ActionCard extends Card {
actionSet.put(2, "Draw Two");
actionSet.put(3, "");
actionSet.put(4, "Draw four");
actionSet.put(5, "Switch");
actionSet.put(5, "Double Skip");
actionSet.put(6, "One More Round");
}
......
......@@ -18,6 +18,9 @@ public class NumberCard extends Card {
@Override
public String toString() {
if (number == -1) {
return coloSet.get(this.getColor());
}
return String.format("%s %s", coloSet.get(this.getColor()), Integer.toString(number));
}
......
import java.io.*;
import java.net.InetAddress;
import java.net.Socket;
import java.net.UnknownHostException;
import java.util.Scanner;
/**
* This class implements java socket client
* @author pankaj
*
*/
public class Client {
public static void main(String[] args) throws UnknownHostException, IOException, ClassNotFoundException, InterruptedException {
//get the localhost IP address, if server is running on some other IP, you need to use that
InetAddress host = InetAddress.getLocalHost();
Scanner sc = new Scanner(System.in);
System.out.println("Please input the port number for room");
Socket socket = new Socket(host.getHostName(), sc.nextInt());
while (true) {
InputStream is = new DataInputStream(socket.getInputStream());
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
String recv = reader.readLine();
if (recv != null && !recv.equals("Invalid response.")) {
String msg = recv.replace('\t', '\n');
System.out.println(msg);
}
while (true && !recv.contains("don't") && !recv.contains("!")) {
String response = sc.nextLine();
if (response != null && !response.contains("\n")) {
OutputStream output = socket.getOutputStream();
PrintWriter writer = new PrintWriter(output, true);
writer.println(response);
System.out.println("================================================");
break;
}
}
if (recv.contains("win")) {
break;
}
}
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment