需要用2个class 其中一个 Card class用int 创建1到13 ,1代表ace,11是jack,12 是queen,13是king 。另外一个是Deck class 需要用循环然后创建卡组 最后是发牌和洗牌然后用toString 输出/
求大神解答! 最好有 代码! 我卡在了第一个class ,按照要求说是需要2个参数,但是class 里怎么创建参数?不是只有 方法method 才行的吗?
还有第二个 构造器 怎么构造 Card这个对象的 array 也就是数组?
Deck of CardsCreate a deck of 52 playing cards! The deck will be able to shuffle itself, and deal cards.
First create a Card class, then build your deck as an array of Card objects.
The Card class will have two parameters, int and String, holding the number of the card ( 1 - 13, where 1 is an ace, 11 is a jack, 12 is a queen, and 13 is the king) and the suit (hearts, clubs, spades and diamonds).
The Deck class should have an Array of 52 Card objects. Use one loop or nested loops in the constructor to create the array or ArrayList of cards.
Once you have created the Card array, you should create methods to shuffle the deck (experiment with efficient ways to do this!) deal a card, and print out the value of the card (using a toString). These are the foundation of all the card games.
Write a driver class to instantiate a deck of cards, shuffle the deck and output a hand of 5 cards.
Hand in only the Card class, and Deck class.
求大神解答! 最好有 代码! 我卡在了第一个class ,按照要求说是需要2个参数,但是class 里怎么创建参数?不是只有 方法method 才行的吗?
还有第二个 构造器 怎么构造 Card这个对象的 array 也就是数组?
Deck of CardsCreate a deck of 52 playing cards! The deck will be able to shuffle itself, and deal cards.
First create a Card class, then build your deck as an array of Card objects.
The Card class will have two parameters, int and String, holding the number of the card ( 1 - 13, where 1 is an ace, 11 is a jack, 12 is a queen, and 13 is the king) and the suit (hearts, clubs, spades and diamonds).
The Deck class should have an Array of 52 Card objects. Use one loop or nested loops in the constructor to create the array or ArrayList of cards.
Once you have created the Card array, you should create methods to shuffle the deck (experiment with efficient ways to do this!) deal a card, and print out the value of the card (using a toString). These are the foundation of all the card games.
Write a driver class to instantiate a deck of cards, shuffle the deck and output a hand of 5 cards.
Hand in only the Card class, and Deck class.