首页 > 编程语言 >COMP2396 可视化卡游戏编程

COMP2396 可视化卡游戏编程

时间:2023-04-24 14:35:30浏览次数:39  
标签:COMP2396 button 编程 should player game 可视化 components cards


COMP2396 Object-oriented programming and Java
Assignment 3: GUI Card Game
Due date: 21st April 2023 (Friday), 23:59
This assignment tests your understanding of GUI programming in Java and your
programming skills You should develop the program using Eclipse and submit an
Eclipse project to Moodle.
In this assignment, you are going to implement a simple card game. The computer will
simulate the dealer. When the game starts, 52 playing cards will be shuffled and the
player is given $100. At each round of the game, both the player and the dealer will be
given 3 cards (they are drawn from the top of the deck). Player will place his/her bet
(you can assume the player always place a positive integer bet). Then before the dealer
opens the cards, the player has a chance to draw AT MOST two cards from the top of
the deck to replace any two of the cards on hand and each card on hand can only be
replaced ONCE. Player will lose the bet if the dealer got a better hand (see below for
explanation), otherwise the player wins the same amount of money as his/her bet.
Rules to determine who has better cards:
J, Q, K are regarded as special cards.
Rule 1: The one with more special cards wins.
Rule 2: If both have the same number of special cards, add the face values of the other
card(s) and take the remainder after dividing the sum by 10. The one with a bigger
remainder wins. (Note: Ace = 1).
Rule 3: The dealer wins if both rule 1 and rule 2 cannot distinguish the winner.
2
User interface components:
Your user interface should contain the following components:
1) 6 JLabel components for holding 6 ImageIcon components. These ImageIcon
components are used to display the cards of the dealer and the player. The image
files can be downloaded from Moodle.
2) 3 JButton components for the player to replace card 1, card 2 and card 3
respectively. Note that a player can replace at most 2 cards on hand and each card
can only be replaced ONCE (Note: 1) the JButton for replacing the corresponding
card should be disabled if that card has already been replaced; 2) After 2 cards
have already been replaced, the 3 JButton should be disabled).
3) 1 JLabel component showing the string “Bet: $” to guide the player to input
his/her bet.
4) 1 JTextField component for the player to input his/her bet (in the form of a
positive integer).
5) 2 JButton components for the player to start the game (i.e. drawing 3 cards from
the dealer’s pack) and to evaluate the result.
(Note: The JButtons for evaluating the result, replacing the cards should be
disabled before the player indicates his/her bet and start the game, they should
only be enabled after the player indicates his/her bet and start the game; The
JButton for starting the game should be disabled after the player places his/her bet
and starts the game, it should only be enabled after the result is displayed,
evaluated and the player still has money.)
6) 2 JLabel components for displaying important messages and the remaining budget
that the player has. They should be placed below the JLabel component showing
the string “Bet: $”, the JTextField component for the player to input his/her bet
and the 2 JButton components for the player to start the game and evaluate the
result.
7) 1 JMenuBar contains the following:
-1 JMenu “Control” contains 1 JMenuItem to quit the game.
A sample user interface is shown on the next page. You can have your own design but
you must include the above mentioned GUI components and all the functionalities
described in this document should be implemented. To ensure your program has
implemented all necessary functions, please refer to the screen capture and the marking
scheme below for your reference.
3
Initial setting:
After player places his/her bet and click Start button:
4
When the player clicks Replace Card button, the corresponding card should be
replaced:
(the following screen capture shows an example when Replace Card 1 button is
clicked)
5
After the player clicks Result button and if the player wins:
After the player clicks Result button, and if the player loses:
6
When the player loses all his/her money, a message notifying game over should be
shown, in addition, the 3 JButton for replacing cards, the JButton for Start and the
JButton for Result should be disabled:
7
When the player clicks Control ? Exit, the game windows should be closed.
8
Marking Scheme
Correct implementation of GUI components: (Total 12%)
[6%] - 6 JLabel components for holding 6 ImageIcon components.
[1%] - 3 JButton components for the player to replace card 1, card 2 and card 3
[1%] - 1 JLabel component showing the string “Bet: $”
[1%] - 1 JTextField component for the player to input his/her bet
[1%] - 2 JButton components for the player to start the game and to evaluate the
result
[1%] - 2 JLabel components for displaying important messages and the remaining
budget that the player has
[1%] - 1 JmenuBar that consists of 1 JMenu “Control” which contains 1 JMenuItem
to quit the game.
Correct functionality of the game: (Total 78%)
[8%] - Implementation of the Start button (i.e. drawing 3 cards from the top of the
dealer’s pack and display the 3 cards after clicking the Start button)
[4%] - Implementation of the disable of “Result” button, and the replace card buttons
before the game starts (4%)
[18%] - Implementation of Replace Card buttons to replace a particular card with the
card that is at the top of the dealer’s pack and the disable of these buttons after the
card is replaced or there have already been 2 cards replaced.
(6% each)
[4%] - Implementation of the disable of “Start” button after the game starts and the
re-enable of the button after the result is displayed, evaluated and the player still has
money.
[18%] - Implementation of evaluating the result with correct rules to determine who
has better cards after clicking the Result button
[5%] - Implementation of showing the dealer’s cards after clicking the Result button
[3%] - Implementation of messages when the player wins/loses
[3%] - Implementation of money incremental/deduction when the player wins/loses
[7%+3%] - Implementation of shuffling the cards and correct amount of player’s
money when a new game is started
[3%] - Implementation of messages and the disable of Replace Card buttons, the
Start button and the Result button when the player loses all his/her money
[2%] - Implementation of exiting the game
JavaDoc (Total 10%)
9
Submission
After completing the assignment, export the project from Eclipse. Please submit the
exported project in a single compressed file (in .zip) to Moodle. Late submission is
not allowed. Do not submit .class files.
After submission, you are advised to download your submission from Moodle to try in
Eclipse to ensure all necessary files are included in the submission.
You will get 0 mark if:
you submit .class files instead of .java source files, or
you submit java source files that cannot be compiled in Eclipse, or
you submit java source files that are downloaded from the Internet, or
you submit java source files from your classmates, or
you submit java source files from friends taken this course last year.
For this assignment, you are required to write JavaDoc for all non-private classes and
non-private class member functions. Programs without JavaDoc comments will lead to
mark deduction. However, you don’t need to generate JavaDoc HTML. Just write
comment blocks in your source program.

 WX:codehelp

标签:COMP2396,button,编程,should,player,game,可视化,components,cards
From: https://www.cnblogs.com/somtimes/p/17349413.html

相关文章

  • 【前端可视化】ECharts中国地图+散点图demo
    <!DOCTYPEhtml><htmllang="en"><head><metacharset="UTF-8"/><metahttp-equiv="X-UA-Compatible"content="IE=edge"/><metaname="viewport"content="w......
  • COMP2212编程概念
    COMP2212ProgrammingLanguageConceptsCourseworkIntroductionInthiscourseworkyouarerequiredtodesignandimplementadomainspecificprogramminglanguageforspecifyingtilingpatterns.Forthepurposesofthisassignmentweconsideratiletobeasq......
  • 实验3 控制语句与组合数据类型应用编程
    实验任务一源代码1importrandom23print('用列表存储随机整数:')4lst=[random.randint(0,100)foriinrange(5)]5print(lst)67print('\n用集合存储随机整数:')8s1={random.randint(0,100)foriinrange(5)}9print(s1)1011print('\n用......
  • 线性SVM决策过程的可视化
    线性SVM决策过程的可视化导入模块fromsklearn.datasetsimportmake_blobsfromsklearn.svmimportSVCimportmatplotlib.pyplotaspltimportnumpyasnp实例化数据集,可视化数据集x,y=make_blobs(n_samples=50,centers=2,random_state=0,cluster_std=0.5)#p......
  • 实验3 控制语句与组合数据类型应用编程
    task1问题1:可以取到100问题2:范围:0、1、2、3、4,不能取到5;范围:1、2、3、4,不能取到5问题3:一定是5问题4:一定是5task2-3book_infos=[{'书名':'昨日的世界','作者':'斯蒂芬.茨威格'},{'书名':'局外人','作者':'阿尔贝.加缪'......
  • 2022.4.23编程一小时打卡
    一、问题描述:定义一个基类,派生出子类,基类有fn1(),fn2(),fn1()是虚函数;子类也有这俩个函数,在主函数中声明子类的一个对象,并通过指针调用这俩个函数。观察程序运行过程。二、解题思路:首先,定义一个基类BaseClass类,其派生出子类DerivedClass类,在主函数中定义基类的指针,调用这俩个函......
  • 实验3 控制语句与组合数据类型应用编程
    task1源代码1importrandom23print('用列表存储随机整数:')4lst=[random.randint(0,100)foriinrange(5)]5print(lst)67print('\n用集合存储随机整数:')8s1={random.randint(0,100)foriinrange(5)}9print(s1)1011print('......
  • 每日编程一小时(第十四天)
    一.问题描述编写程序:用二分法在有序表{3,4,10,13,33,42,46,63,76,78,95,96,120}中查找一个给定的数。 二.设计思路1.定义一个数组a存入上面的数,按从小到大排序2.输入一个数n3.设计一个函数f(a,0,13,n),取中间值mid=1+13/2,比较a[mid]和n的大小,若right-left>1&&a[mid]!=x,有......
  • 编程一小时2023.4.23
    1.#include<bits/stdc++.h>usingnamespacestd;stringa,s;intb[1005],t,c[1005];voiddivision(){for(inti=t-1;i>=0;i--){if(b[i]%2)b[i-1]+=10;b[i]/=2;}while(b[t-1]==0)t-......
  • 【开源项目】无锡~超经典智慧城市智慧无锡 CIM/BIM数字孪生可视化项目——开源工程及
    智慧无锡免费提供工程和源码,为城市管理和发展提供更智能化的解决方案。项目介绍智慧无锡项目利用数字孪生技术,将无锡市的地理信息、公共数据和实时监测数据进行整合,以数字化形式呈现城市的各种信息和场景。在工程中,利用AI处理地形影像,在溪梁区使用高精度的max模型,其他区域使用AI生......