甲板类构造函数 [英] deck class constructor

查看:79
本文介绍了甲板类构造函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我正在尝试解决这个卡片问题,其中我有一些课程和测试课程。其他一切都已完成。我只需要帮助正确实现这些方法。事情就是这样:


我给了类Suit.java,PlayingCard.java,FaceCard.java,NumberCard.java,Deck.java,CardTest。 java

So I''m trying to work on this problem of deck of cards wherein I have a few classes along with a tester class. Everything else is done. I just need help with implementing the methods properly. Here''s how the thing goes:

I''m given the classes Suit.java, PlayingCard.java, FaceCard.java, NumberCard.java, Deck.java, CardTest.java

展开 | 选择 | Wrap | 行号

推荐答案

1。使PlayCard不抽象。


2.你的构造函数是

public NumberCard(int r,Suit s){

所以当你构建了套牌,第二个参数应该是套装。现在它是:

卡[count] =抽象PlayingCard(排名,套装);

我想你想要:

卡[计数] ] =抽象的PlayCard(等级,适合[西装]);


3.但你必须改变套装的顺序。


4.此外,在for循环之前移动计数初始化,否则你将始终只设置牌[0],而不是整个牌组。
1. Make PlayingCard not abstract.

2. Your constructor is
public NumberCard(int r, Suit s) {
so when you construct the deck, the 2nd argument should be a suit. Right now it is:
cards [count] = abstract PlayingCard(rank,suit);
I think you want:
cards [count] = abstract PlayingCard(rank,suits[suit]);

3. but you have to change the order of the suits.

4. Further, move the count initialization before the for loops, otherwise you''ll always only be setting cards[0], and not the whole deck.


好的,所以我做了改变你问我..还是给我看了以下错误:

Deck.java:26:非法开始表达

cards [count] =抽象PlayingCard(排名,西装[套装]);

^

1错误

箭头指向a抽象和单词卡之前[count]


这里'我的程序现在是什么样的

Ok so i did the changes u asked me to..it stilll shows me the following error:
Deck.java:26: illegal start of expression
cards [count] = abstract PlayingCard(rank,Suit[suits]);
^
1 error
the arrow is pointed at a of the abstract and the word cards comes before[count]

here''s how my program looks like now

展开 < span class =codeDivider> | 选择 | Wrap | 行号


我认为删除抽象部分已完成....但我有另一个问题。那个构造部分仍然无法工作。


这是显示的错误

Deck.java:26:找不到符号

符号:变量套装

位置:类甲板

卡[count] = PlayingCard(等级,套装[套装]);

^

Deck.java:26:不兼容的类型

找到:java.lang.String []
需要
:int

卡片[count] = PlayingCard(等级,套装[套装]);

^

2个错误


卡[计数] = PlayingCard(排名,西装[西装]);


这是我所做的改变。 plzzz help !!!
I think the removing abstract part is done....but i have another issue. That construction part still doesnt work.

this is the error that shows
Deck.java:26: cannot find symbol
symbol : variable Suit
location: class Deck
cards [count] = PlayingCard( rank,Suit[suits]);
^
Deck.java:26: incompatible types
found : java.lang.String[]
required: int
cards [count] = PlayingCard( rank,Suit[suits]);
^
2 errors

cards [count] = PlayingCard( rank,Suit[suits]);

and this is the change i made. plzzz help!!!


这篇关于甲板类构造函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆