我需要创建一个名为box的类,它使用链表来存储包含两个字符串作为输入的抽认卡。
public class FlashCard {
public static String challenge;
public static String response;
public FlashCard(String front, String back)
{
double a = Math.random();
if(a > 0.5) challenge = front;
else challenge = back;
if(a < 0.5) response = front;
else response = back;
}
private static String getChallenge()
{
return challenge;
}
private static String getResponse(String in)
{
return response;
}
public static void main(String[] args)
{
FlashCard card = new FlashCard("Ryan Hardin", "Student at UAB");
System.out.print(challenge);
}
}
这是我的盒子类,它使用链接列表作为实例变量来存储卡片,但不断收到错误消息。
import java.util.LinkedList;
public class Box {
private LinkedList<FlashCard> data;
public Box() {
this.data = new LinkedList<FlashCard>();
}
public Box addCard(FlashCard r) {
Box one = this;
one.data = data.add(0,r);
return one;
}
答案 0 :(得分:0)