首页 > 编程语言 >EBU4201 I java编程

EBU4201 I java编程

时间:2023-06-03 17:55:27浏览次数:45  
标签:java 编程 number should EBU4201 Rabbit images your must


EBU4201 Introductory Java Programming 2022/23
Mini Project
Task 1 [30 marks]
SumItUp is a simple application for children where they can practise their counting and adding
skills (see Figure 1).
Figure 1 First launch with some input values entered
A random number of Rabbit images ranging from 1 to 10 are displayed for each operand and the
user is expected to enter the values of the two operands and the result of adding the two operands,
in the given text fields. When the user clicks on the button ‘Check!’, one of two things can happen:
Case 1: all three input values are correct
i) the text changes to ‘"Correct! Have another go?"’.
ii) the number of Rabbit images displayed for each of the two operands changes. See Figure
2 for an example.
iii) the three text fields are reset (i.e. they are made empty).
2/5
Case 2: at least one of the input values entered is incorrect
i) the text changes to ‘Wrong! Try again!’.
ii) the number of Rabbit images displayed does NOT change.
iii) the text fields do NOT change.
Figure 2 Action following Case 1
Implement SumItUp as a Java application. You application must satisfy ALL the specific
requirements given below:
a) The title of the top-level container must be ‘Welcome to SumItUp!’.
b) The initial text should be ‘Enter two operands, result and click on 'Check!'’. See Figure
1.
c) There should be no more than 4 Rabbit images per row. See Hint 1.
d) The text fields should be wide enough to display at least TWO characters.
e) The button ‘Check!’ must not resize when the GUI is resized. See Hint 2 and Figure
3.
f) The ‘plus sign’ icon should appear vertically centered between the two sets of Rabbit
images and must not resize when the GUI is resized. See Hint 2 and Figure 3.
g) When first launched and whenever a correct answer is given, the number of displayed
Rabbit images for each operand should change to any number between 1 and 10
(inclusive). See Hint 3 and Hint 4.
Note: It is possible for the next number(s) to be the same as the current number(s).
h) Nothing should happen if the user clicks the ‘Check!’ button while at least one of the
text fields are empty, i.e. no errors should be thrown in this case.
Note: You can assume that only a numeric value will be entered into the text fields.
3/5
Hint 1: Use an array of JLabel components for the Rabbit images. The following constructor
may be helpful for the ‘plus sign’ icon.
public JLabel(Icon image)
A Rabbit image and ‘plus sign’ image are provided. You must use these images.
Hint 2: Consider using containers within other containers and using layouts intelligently.
Hint 3: Suggested approach for displaying images: look up the following method in the class
javax.swing.JLabel.
public void setIcon(Icon icon)
Hint 4: Suggested approaches for displaying a variable number of images: classes
java.util.Random OR java.lang.Math.
Note: All the necessary files should be placed in a directory called Task1.You can choose
whether to place the image files directly under Task1 or within a sub-directory. Whichever
approach you take, the images must be displayed on the GUI without having to move the
image files to different locations within your directory structure.
Also note that your application must run as expected from the command line on OpenJDK
19.0.2.
Figure 3 GUI Resized
Task 2 [10 marks]
You may notice that entering a non-numeric value and clicking the ‘Check!’ button will cause
a run-time error on the console. Therefore, your second task is to improve the application
developed in Task 1 to ensure the user is only allowed to supply valid input values, i.e. a
4/5
number between 1 and 10 (inclusive). The application must still function as specified in Task
1 although you may remove the ‘Check!’ button if you wish.
Hint: Use another appropriate component in place of the text field.
Note: All the necessary files (including any reused ones from Task 1) should be placed in a
directory called Task2.
Documentation [10 marks]
You must include:
a. Generated Javadocs
b. Internal comments in your code.
c. User Manual. This should be no more than 2 pages and include how to run the program
(both how to start and how to use it).
Note: All documentation files should be placed in a directory called Documentation.
Extra Credit [5 marks]

WX:codehelp
Extra marks from this section can be used to top up your final grade for this project. Maximum
mark is still 50.
Further improve your application such that the maximum number of Rabbit images displayed
for each operand can be any number between 10 and MAX (inclusive), specified as a
command line argument. E.g. assuming your class is called SumItUpExtra, the command
Java SumItUpExtra 20
will launch a GUI similar to Figure 1 where the maximum number of Rabbit images displayed
per operand will be 20. Whenever a correct answer is entered, the number of Rabbit images
per operand will change to any number between 1 and 20 (inclusive). There should be no more
than 5 Rabbit images per row.
MAX must be calculated as follows.
If the last digit of your QM student number is 0-4, MAX = 20
If the last digit of your QM student number is 5-9, MAX = 25
If no command line argument is given OR a number outside the valid range is given, the
program must terminate printing out an appropriate error message to the console. You can
assume only a numeric value will be given as the argument.
Note: All the necessary files (including any reused ones from Task 1 and Task 2) should be
placed in a directory called ExtraCredit.
5/5
Important notes:
1. All three directories must be included in a zip file. The filename must be your QM
Student Number.
2. You should design your classes properly, following object oriented principles. E.g. do
NOT write everything in the main method, keep code repetition to a minimum (i.e. use
methods), do NOT use static methods unless there is a good reason. There will be
marks allocated for good design.

 WX:codehelp

标签:java,编程,number,should,EBU4201,Rabbit,images,your,must
From: https://www.cnblogs.com/simpleyfc/p/17454317.html

相关文章

  • Java实战(第2版)学习笔记
    基本知识函数式编程:Java8里将代码传递给方法的功能(同时也能够返回代码并将其包含在数据结构中)还让我们能够使用一整套新技巧,通常称为函数式编程。没有共享的可变数据,以及将方法和函数(即代码)传递给其他方法的能力,这两个要点是函数式编程范式的基石。行为参数化:将方法(你的代码)作......
  • java子线程中获取父线程的threadLocal中的值
    1packagecom.example.springbootstudy.test.threadLocal;23publicclassBaseTest{45publicstaticfinalInheritableThreadLocal<String>inheritableThreadLocal=newInheritableThreadLocal<>();67publicstaticfinalThrea......
  • Java8之Stream的学习
    一、概念理解Stream可以由数组或集合创建,对流的操作分为两种:中间操作,每次返回一个新的流,可以有多个。终端操作,每个流只能进行一次终端操作,终端操作结束后流无法再次使用。终端操作会产生一个新的集合或值。二、Stream的创建publicclassStreamDemo{publicstaticvoidmain(......
  • java继承
    1.为什么要使用继承多类之间拥有相同的属性或是方法;解决方式是将相同的属性和方法抽取出来封装到一个新的类中,并继承新的类。2.继承语法AextendsB如果AextendsB得出结论;A是B的子类;B是A的父类java中一个类只能继承一个父类(单继承关系)继承的关键字是extends3.supersupe......
  • Java使用SSLContext请求https
    //首先实现信任的管理器类ublic class HttpsUtil {     private static class TrustAnyTrustManager implements X509TrustManager {         public void checkClientTrusted(X509Certificate[] chain, String authType)          ......
  • JAVA的springboot+vue医疗预约服务管理信息系统,医院预约管理系统,附源码+数据库+论文+P
    1、项目介绍会员制医疗预约服务管理信息系统是针对会员制医疗预约服务管理方面必不可少的一个部分。在会员制医疗预约服务管理的整个过程中,会员制医疗预约服务管理系统担负着最重要的角色。为满足如今日益复杂的管理需求,各类的管理系统也在不断改进。本课题所设计的是会员制医疗......
  • 实验5 文件应用编程
    实验任务6task6#读取并处理原始数据withopen('data6.csv','r',encoding='gbk')asf:old_data=f.read().split('\n')delold_data[0]#四舍五入得到新数据new_data=[]foriinrange(len(old_data)):ifeval(old_data[i])+flo......
  • Java High Level Rest Client---操作索引库
    操作索引库初始化RestClient引入es的RestHighLevelClient依赖:点击查看代码<dependency><groupId>org.elasticsearch.client</groupId><artifactId>elasticsearch-rest-high-level-client</artifactId> <version>7.12.1</version>......
  • Java High Level Rest Client---操作文档
    新增文档1)创建Request对象2)准备请求参数,也就是DSL中的JSON文档3)发送请求代码示例:点击查看代码//新增文档@TestpublicvoidaddDoc()throwsException{//根据id查出酒店数据Hotelhotel=iHotelService.getById(36934L);//将酒店......
  • 1. C++编程简介
    勿在浮沙筑高台课程:C++面向对象程序设计。面向对象,它是一个观念。那么我们要用这种观念来写程序,需要面向对象的语言,而C++就是一个支持面向对象观念的一种语言。上这门课你该具备什么样的基础呢?只要你有这些基础就够了,你曾经学过某一种procedurelanguage,最好是C语言,但是......