我是编程新手,如果它看起来很糟糕,请原谅我。我不太确定我在做什么。
当我编译我的代码时,我收到以下错误:
error: constructor Card in class Card cannot be applied to given types;
required: no arguments
found: String, String, int
reason: actual and formal arguments differ in length
这是我的代码:
public void testConvenienceConstructor() {
System.out.println("Card...");
Card instance = new Card("4", DIAMONDS, 4);
assertEquals("4", instance.getName());
assertEquals(DIAMONDS, instance.getSuit());
assertEquals(4, instance.getValue());
这是我的 Card 类代码:
package model;
public class Card implements CribbageConstants {
//-----fields-----
private String name; //the name of the card
private String suit; //the suit of the card
private int value; //the value of the card
//---------- Constructors ---------
/**
* No argument constructor - set default values for card
*/
public Card() {
name = "ACE";
suit = "CLUBS";
value = 1;
}
//-------------- Utility methods --------------
/**
* Provide a text representation of a card.
*
* @return The banana's name, suit, and value
*/
public String getName() {
return name;
}
public String getSuit() {
return suit;
}
public int getValue() {
return value;
}
//------mutator-----
public void setName(String name) {
this.name = name;
}
public void setSuit(String suit) {
this.suit = suit;
}
public void setValue(int value) {
this.value = value;
}
//-----------utility methods------------
}