Commit b0439da9 authored by 9731301's avatar 9731301

Add print method

parent c674abee
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
<mapping directory="$PROJECT_DIR$/src" vcs="Git" />
</component>
</project>
\ No newline at end of file
......@@ -2,16 +2,8 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="608d52d9-3dd7-4e55-84b9-421c09e25ee0" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/src/Card.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Card.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/ColoredCard.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/ColoredCard.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Draw2Card.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Draw2Card.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/MotiveCard.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/MotiveCard.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/ReverseCard.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/ReverseCard.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/SkipCard.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/SkipCard.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/User.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/User.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Wild4.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Wild4.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/WildCard.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/WildCard.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/WildColor.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/WildColor.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/vcs.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/vcs.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
......@@ -26,7 +18,7 @@
</option>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/src" />
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="ProjectId" id="1aPagVKczd51qAfmeiqRTIQtfoK" />
<component name="ProjectLevelVcsManager" settingsEditedManually="true" />
......@@ -66,6 +58,7 @@
<updated>1586639793866</updated>
<workItem from="1586639798096" duration="7822000" />
<workItem from="1586696062533" duration="20074000" />
<workItem from="1586769548038" duration="8743000" />
</task>
<servers />
</component>
......@@ -73,30 +66,50 @@
<option name="version" value="1" />
</component>
<component name="WindowStateProjectService">
<state x="574" y="97" key="#com.intellij.ide.util.MemberChooser" timestamp="1586718271606">
<state x="574" y="97" key="#com.intellij.ide.util.MemberChooser" timestamp="1586782366631">
<screen x="0" y="0" width="1536" height="824" />
</state>
<state x="574" y="97" key="#com.intellij.ide.util.MemberChooser/0.0.1536.824@0.0.1536.824" timestamp="1586718271606" />
<state width="1493" height="194" key="GridCell.Tab.0.bottom" timestamp="1586718479498">
<state x="574" y="97" key="#com.intellij.ide.util.MemberChooser/0.0.1536.824@0.0.1536.824" timestamp="1586782366631" />
<state width="1493" height="261" key="GridCell.Tab.0.bottom" timestamp="1586783306694">
<screen x="0" y="0" width="1536" height="824" />
</state>
<state width="1493" height="194" key="GridCell.Tab.0.bottom/0.0.1536.824@0.0.1536.824" timestamp="1586718479498" />
<state width="1493" height="194" key="GridCell.Tab.0.center" timestamp="1586718479498">
<state width="1493" height="261" key="GridCell.Tab.0.bottom/0.0.1536.824@0.0.1536.824" timestamp="1586783306694" />
<state width="1493" height="261" key="GridCell.Tab.0.center" timestamp="1586783306694">
<screen x="0" y="0" width="1536" height="824" />
</state>
<state width="1493" height="194" key="GridCell.Tab.0.center/0.0.1536.824@0.0.1536.824" timestamp="1586718479498" />
<state width="1493" height="194" key="GridCell.Tab.0.left" timestamp="1586718479498">
<state width="1493" height="261" key="GridCell.Tab.0.center/0.0.1536.824@0.0.1536.824" timestamp="1586783306694" />
<state width="1493" height="261" key="GridCell.Tab.0.left" timestamp="1586783306693">
<screen x="0" y="0" width="1536" height="824" />
</state>
<state width="1493" height="194" key="GridCell.Tab.0.left/0.0.1536.824@0.0.1536.824" timestamp="1586718479498" />
<state width="1493" height="194" key="GridCell.Tab.0.right" timestamp="1586718479498">
<state width="1493" height="261" key="GridCell.Tab.0.left/0.0.1536.824@0.0.1536.824" timestamp="1586783306693" />
<state width="1493" height="261" key="GridCell.Tab.0.right" timestamp="1586783306694">
<screen x="0" y="0" width="1536" height="824" />
</state>
<state width="1493" height="194" key="GridCell.Tab.0.right/0.0.1536.824@0.0.1536.824" timestamp="1586718479498" />
<state x="107" y="217" key="com.intellij.ide.util.TipDialog" timestamp="1586696159864">
<state width="1493" height="261" key="GridCell.Tab.0.right/0.0.1536.824@0.0.1536.824" timestamp="1586783306694" />
<state width="1493" height="261" key="GridCell.Tab.1.bottom" timestamp="1586783306694">
<screen x="0" y="0" width="1536" height="824" />
</state>
<state x="107" y="217" key="com.intellij.ide.util.TipDialog/0.0.1536.824@0.0.1536.824" timestamp="1586696159864" />
<state width="1493" height="261" key="GridCell.Tab.1.bottom/0.0.1536.824@0.0.1536.824" timestamp="1586783306694" />
<state width="1493" height="261" key="GridCell.Tab.1.center" timestamp="1586783306694">
<screen x="0" y="0" width="1536" height="824" />
</state>
<state width="1493" height="261" key="GridCell.Tab.1.center/0.0.1536.824@0.0.1536.824" timestamp="1586783306694" />
<state width="1493" height="261" key="GridCell.Tab.1.left" timestamp="1586783306694">
<screen x="0" y="0" width="1536" height="824" />
</state>
<state width="1493" height="261" key="GridCell.Tab.1.left/0.0.1536.824@0.0.1536.824" timestamp="1586783306694" />
<state width="1493" height="261" key="GridCell.Tab.1.right" timestamp="1586783306694">
<screen x="0" y="0" width="1536" height="824" />
</state>
<state width="1493" height="261" key="GridCell.Tab.1.right/0.0.1536.824@0.0.1536.824" timestamp="1586783306694" />
<state x="107" y="217" key="com.intellij.ide.util.TipDialog" timestamp="1586769552313">
<screen x="0" y="0" width="1536" height="824" />
</state>
<state x="107" y="217" key="com.intellij.ide.util.TipDialog/0.0.1536.824@0.0.1536.824" timestamp="1586769552313" />
<state x="425" y="187" key="run.anything.popup" timestamp="1586782658252">
<screen x="0" y="0" width="1536" height="824" />
</state>
<state x="425" y="187" key="run.anything.popup/0.0.1536.824@0.0.1536.824" timestamp="1586782658252" />
<state x="431" y="145" width="672" height="678" key="search.everywhere.popup" timestamp="1586717206978">
<screen x="0" y="0" width="1536" height="824" />
</state>
......
public abstract class Card {
protected String name;
private int score;
public Card(int score) {
......@@ -12,4 +13,10 @@ public abstract class Card {
public void setScore(int score) {
this.score = score;
}
public abstract String toString();
public abstract void print();
}
......@@ -3,19 +3,27 @@
*/
public class ColoredCard extends Card {
private String color;
public static final String set = "\u001B[0m";
public static final String green = "\u001B[32m";
public static final String red = "\u001B[31m";
public static final String yellow = "\u001B[33m";
public static final String blue = "\u001B[34m";
/**
* create a Colored card that according to subClasses create a special kind of colored cards
*
* @param color
* @param score
*/
public ColoredCard(String color , int score) {
public ColoredCard(String color, int score) {
super(score);
setScore(score);
setColor(color);
}
/**
* get the color of card
* get the color of card
*
* @return
*/
public String getColor() {
......@@ -25,4 +33,29 @@ public class ColoredCard extends Card {
public void setColor(String color) {
this.color = color;
}
@Override
public String toString() {
String s ="|$$$$$$$$$$$$$$$|\n";
s +="| |\n";
s +="| "+name+" |\n";
s +="| |\n";
s +="|$$$$$$$$$$$$$$$|\n";
return s;
}
@Override
public void print() {
String first = null;
if (color.equals("red")) {
first = red;
} else if (color.equals("yellow")) {
first = yellow;
} else if (color.equals("blue")) {
first = blue;
} else if (color.equals("green")) {
first = green;}
System.out.println(first + toString() + set);
}
}
......@@ -8,10 +8,13 @@ public class Draw2Card extends MotiveCard {
*/
public Draw2Card(String color, int score) {
super(color, score);
name = "+2";
}
@Override
public void move() {
}
}
......@@ -10,4 +10,5 @@ public abstract class MotiveCard extends ColoredCard{
}
public abstract void move();
}
\ No newline at end of file
......@@ -5,5 +5,6 @@ public class NumericalCard extends ColoredCard {
public NumericalCard(String color, int score, int number) {
super(color, score);
this.number = number;
name= Integer.toString(number);
}
}
......@@ -8,10 +8,13 @@ public class ReverseCard extends MotiveCard {
*/
public ReverseCard(String color, int score) {
super(color, score);
name = "reverse";
}
@Override
public void move() {
}
}
public class SkipCard extends MotiveCard {
/**
* create a Colored card that according to subClasses create a special kind of colored cards
*
......@@ -8,6 +9,7 @@ public class SkipCard extends MotiveCard {
*/
public SkipCard(String color, int score) {
super(color, score);
name = "skip" ;
}
@Override
......
......@@ -6,6 +6,7 @@ public class Uno {
int numOfPlayers;
ArrayList<User> users = new ArrayList<>();
ArrayList<Card> remainingCards = new ArrayList<>();
GivingCard givingCard = new GivingCard();
Scanner scanner = new Scanner(System.in);
for (int i = 0 ; i < 2 ; i++) {
for (int numNumericalCard = 1; numNumericalCard < 10; numNumericalCard++) {
......@@ -64,7 +65,9 @@ public class Uno {
}
for (Card c : remainingCards){
c.print();
}
while (true) {//set num of players at first
......
......@@ -2,8 +2,10 @@ public class Wild4 extends WildCard {
public Wild4(int score) {
super(score);
name = "+4";
}
@Override
public void giveCard() {
......
......@@ -4,4 +4,20 @@ public abstract class WildCard extends Card {
super(score);
}
public abstract void giveCard();
@Override
public String toString(){
String s = "|$$$$$$$$$$$$$$$|\n";
s += "| |\n";
s += "| "+name+" |\n";
s += "| |\n";
s += "|$$$$$$$$$$$$$$$|\n";
return s;
}
@Override
public void print(){
System.out.println(toString());
}
}
public class WildColor extends WildCard {
public WildColor(int score) {
super(score);
name = "setColor";
}
@Override
public void giveCard() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment