Answer:
Explanation:
//Java program
class UnoCard{
private String color;
private int value;
public UnoCard(String color , int val) {
this.color = color;
value = val;
}
public String getColor() {
return color;
}
//set the color of the card
public void setColor(String color ) {
this.color = color;
}
//get the value of the card
public int getValue() {
return value;
}
//set the value of the card
public void setValue(int val) {
value = val;
}
//return true if card has same value or
//same color as the card
//return false otherwise
public boolean isMatch(UnoCard card) {
return (this.value==card.value)||(this.color==card.color);
}
}
public class Card {
public static void main(String args[]) {
UnoCard card1 = new UnoCard("Red",10);
UnoCard card2 = new UnoCard("Green",10);
UnoCard card3 = new UnoCard("Blue",15);
if(card1.isMatch(card2))System.out.println("Match");
else System.out.println("No Match");
if(card2.isMatch(card3))System.out.println("Match");
else System.out.println("No Match");
}
}