Commit 7eb21396 authored by amir's avatar amir

initial

parent 8b538d48
Pipeline #3910 failed with stages
package com.company;
public class Black extends Card {
private int blackType; //0 for choose color, 1 == wildDraw
public Black(String color, int blackType) {
super(color);
this.blackType = blackType;
}
public void chooseNextCardColor(){
}
@Override
public String toString() {
return "Black{" +
"blackType=" + blackType +
'}';
}
}
package com.company;
public class Card {
protected String cardColor;
private boolean isSeen = false;
public Card(String color){
this.cardColor = color;
}
public int turnSkip(){
return 1;
}
@Override
public String toString() {
return "Card{" +
"cardColor='" + cardColor + '\'' +
'}';
}
public boolean isSeen() {
return isSeen;
}
public void setSeen(boolean seen) {
isSeen = seen;
}
}
package com.company;
public class Colored extends Card {
private int colorType; // 0 for numeric, 1 == movement
public Colored(String color, int colorType) {
super(color);
if (colorType == 1 || colorType == 0)
this.colorType = colorType;
}
public boolean checkEquality(Colored coloredToCompare){
if (cardColor.equals(coloredToCompare.cardColor) || colorType == coloredToCompare.colorType)
return true;
return false;
}
@Override
public String toString() {
return "Colored{" +
"colorType=" + colorType +
'}';
}
}
package com.company;
public class Draw extends Movemention {
public Draw(String color, int colorType, int moveType) {
super(color, colorType, moveType);
}
@Override
public String toString() {
return "Draw{ " + super.toString();
}
}
package com.company;
import java.util.ArrayList;
import java.util.Random;
public class Main {
public static void main(String[] args) {
ArrayList <Card> cards = new ArrayList<>();
String Color; String Color1;
for (int i = 1; i < 5; i++){
switch (i){
case 1:
Color = "Red";
break;
case 2:
Color = "Yellow";
break;
case 3:
Color = "Green";
break;
case 4:
Color = "Blue";
break;
default:
throw new IllegalStateException("Unexpected value: " + i);
}
for (int j = 0; j < 10; j++) {
Numeric numeric = new Numeric(Color, 0, j);
cards.add(numeric);
}
Skip skip = new Skip(Color, 1, 0);
cards.add(skip);
Reverse reverse = new Reverse(Color, 1, 1);
cards.add(reverse);
Draw draw = new Draw(Color, 1, 2);
cards.add(draw);
Black black = new Black("Black", 0);
cards.add(black);
}
for (int i = 1; i < 5; i++){
switch(i){
case 1:
Color1 = "Red";
break;
case 2:
Color1 = "Yellow";
break;
case 3:
Color1 = "Green";
break;
case 4:
Color1 = "Blue";
break;
default:
throw new IllegalStateException("Unexpected value: " + i);
}
for (int j = 1; j < 10; j++) {
Numeric numeric = new Numeric(Color1, 0, j);
cards.add(numeric);
}
Skip skip = new Skip(Color1, 1, 0);
cards.add(skip);
Reverse reverse = new Reverse(Color1, 1, 1);
cards.add(reverse);
Draw draw = new Draw(Color1, 1, 2);
cards.add(draw);
WildDraw wildDraw = new WildDraw("Black", 1);
cards.add(wildDraw);
}
//System.out.println(cards.size());
/*for (int i = 0; i < 108; i++){
System.out.println(cards.get(i).toString());
}*/
Random r = new Random();
ArrayList<Player> players = new ArrayList<>();
for (int i = 1; i < 5; i++) {
Player p = new Player();
players.add(p);
for (int j = 1; j < 8; j++){
if (cards.get(r.nextInt(108)).isSeen()){
do{
r.nextInt(108);
}while(cards.get(r.nextInt(108)).isSeen());
}
p.getPlayerCards().add(cards.get(r.nextInt(108)));
cards.get(r.nextInt(108)).setSeen(false);
}
p.printAllCards(i);
}
// unicode of black color: "\033[0;30m"
// unicode of red color: "\033[0;31m"
// unicode of green color: "\033[0;32m"
// unicode of yellow color: "\033[0;33m"
// unicode of blue color: "\033[0;34m"
// unicode of forbidden: "\u29B8"
/*for (int i = 1; i < 4; i++){
System.out.print("\033[0;31m" + "|");
if ((i == 1) || (i == 3)){
for (int j = 1; j < 6; j++)
System.out.print("$");
}
else{
System.out.print(" ");
int s;
if (i == 2) {
s = 0;
System.out.print("0");
}
else
s = 1;
for (int j = 1; j < 3 + s; j++)
System.out.print(" ");
}
System.out.println("|");
}*/
}
}
package com.company;
public class Movemention extends Colored {
private int moveType; // 0 for skip, 1 == reverse, 2 == Draw
public Movemention(String color, int colorType, int moveType) {
super(color, colorType);
this.moveType = moveType;
}
@Override
public int turnSkip() {
return super.turnSkip();
}
@Override
public String toString() {
return "cardColor='" + cardColor + '\'' + '}';
}
}
package com.company;
public class Numeric extends Colored {
private int number;
public Numeric(String color, int colorType, int number) {
super(color, colorType);
this.number = number;
}
@Override
public String toString() {
return "Numeric{ Color=" + cardColor +
", number=" + number + '}';
}
}
package com.company;
import java.util.ArrayList;
import java.util.Iterator;
public class Player {
private ArrayList<Card> playerCards = new ArrayList<>();
private int playerPoint;
public ArrayList<Card> getPlayerCards() {
return playerCards;
}
public void printAllCards(int playerNumber){
System.out.println("Player" + playerNumber + ":");
Iterator<Card> cardIterator = playerCards.iterator();
while (cardIterator.hasNext()){
Card c = cardIterator.next();
System.out.println(c.toString());
}
System.out.println();
}
}
package com.company;
public class Reverse extends Movemention {
public Reverse(String color, int colorType, int moveType) {
super(color, colorType, moveType);
}
@Override
public int turnSkip() {
return -1;
}
@Override
public String toString() {
return "Reverse{ " + super.toString();
}
}
package com.company;
public class Skip extends Movemention {
public Skip(String color, int colorType, int moveType) {
super(color, colorType, moveType);
}
@Override
public String toString() {
return "Skip{ " + super.toString();
}
}
package com.company;
public class WildDraw extends Black {
public WildDraw(String color, int type) {
super(color, type);
}
@Override
public int turnSkip() {
return super.turnSkip();
}
@Override
public String toString() {
return super.toString();
}
}
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