跳至主要內容

Project A

AI悦创原创Python 一对一教学uicPython 一对一教学uic大约 11 分钟...约 3217 字

Diploma of IT

资讯科技文凭

Programming Fundamentals

编程基础

SEMESTER 3 2022

第三学期 2022

Weight: 15%

DUE : Week 6

重量:15%

截止日期:第六周

ASSESSMENT TASK 1 : CREATING BASIC JAVA CLASSES AND METHODS

评估任务1:创建基本 Java 类和方法

TASK DESCRIPTION

任务描述

This project requires you to write a basic Java classes with attributes and methods. Methods required include an alternate constructor, methods to display output and methods to read user input. Code must be written that creates objects and then calls methods for these objects.

这个项目要求您编写具有属性和方法的基本 Java 类。所需的方法包括备用构造函数、显示输出的方法和读取用户输入的方法。必须编写代码来创建对象,然后调用这些对象的方法。

OBJECTIVES

目标

  • Demonstrate a working knowledge of the basic constructs in the object-oriented language Java

展示对面向对象语言Java基本结构的实际应用知识。

  • Use the BlueJ programming environment to build simple software systems

使用 BlueJ 编程环境构建简单的软件系统。

  • Design and code a software system that correctly implements a solution to a small problem defined by a specification, and follows specific design rules

根据规范设计并编写一个软件系统,正确实现解决一个小问题的方案,并遵循特定的设计规则。

  • Comprehend and use basic program control constructs of sequence and selection

理解并使用基本的程序控制结构,如顺序和选择。

BRIEF

简要

This is a take home assessment to evaluate your understanding of object oriented concepts taught so far in IPRG001. The assessment will be composed of three (3) parts: the scenario, the code and explanation (including proof of testing).

这是一份关于IPRG001课程中迄今为止所教授的面向对象概念的家庭作业评估。评估将包括三(3)个部分:情景、代码及解释(包括测试证明)。

The scenario

情景:

You will decide on the scenario and develop a back story for your program – it could be a game of some sort or simply display some information about your chosen things in a specific way.

您将决定情景并为您的程序制定一个背景故事,可以是某种类型的游戏,或者以特定方式显示您选择的事物的一些信息。

Choose two objects – they could be your favourite things e.g. a book, a game, an animal (real or imaginary), a character (real or imaginary) etc.

选择两个对象,它们可以是您最喜欢的事物,例如一本书、一款游戏、一种动物(真实或虚构)、一个角色(真实或虚构)等。

The code

代码:

Create two classes (class1 & class2, one for each thing – choose a good name for each class), for each class:

为每个事物创建两个类(class1和class2,为每个类选择一个好名字),对于每个类:

  • Identify at least 3 attributes – an int/double, a String, a boolean and a constant must be present in at least one of the classes.

至少确定3个属性 - 至少在一个类中包含一个int/double、一个String、一个布尔值和一个常量。

  • Design an alternate constructor.

设计一个备用构造函数。

  • Create the accessors and mutators for each attribute.

为每个属性创建访问器和修改器。

  • Design a suitable toString()

设计一个合适的 toString() 方法。

Create a main class (choose a name for it). Create a Scanner object as a local variable in the main class – where ever it is needed. The main class creates an object of class1 and an object of class2 as attributes – choose appropriate names for them. The default constructor should initialise both objects. Each object’s contents should be displayed using the toString().

创建一个主类(为其选择一个名称)。在主类中需要的地方创建一个Scanner对象作为局部变量。主类将创建一个class1对象和一个class2对象作为属性 - 为它们选择合适的名称。默认构造函数应初始化这两个对象。应使用toString()方法显示每个对象的内容。

User entry must change both objects in some way (using mutators).

用户输入必须以某种方式修改这两个对象(使用修改器)。

User must be presented with a decision and the response processed appropriately using an if statement.

用户必须面临一个决策,并使用if语句适当处理响应。

Use multiple methods in the main class - where appropriate.

在适当的情况下,在主类中使用多个方法。

The explanation:

解释:

You will explain the code you wrote and any problems you encountered and how you fixed them. At minimum you need to identify :

您需要解释您编写的代码以及您遇到的任何问题以及如何解决它们。至少您需要确定:

  • Basic Class structure – what does a class have

基本类结构 - 类具有什么特点

  • Attributes – what attributes did you choose for each class and why

属性 - 您为每个类选择了哪些属性以及为什么选择它们

  • Alternate constructors – what parameters did you chose and why

备用构造函数 - 您选择了哪些参数以及为什么选择它们

  • Non-void and void methods – which methods are void and non-void and why

非void和void方法 - 哪些方法是void和非void,以及为什么选择它们

  • Accessor – which methods are accessors

访问器 - 哪些方法是访问器

  • Mutators – which methods are mutators

修改器 - 哪些方法是修改器

  • Access modifiers – what modifiers are used in your code and why

访问修饰符 - 您的代码中使用了哪些修饰符以及为什么使用它们

  • Constants – which values are stored as constants, what modifier did you use and why.

常量 - 存储了哪些值作为常量,您使用了什么修饰符以及为什么使用它们。

  • toString() – what attributes did you include and why

toString() - 您包括了哪些属性以及为什么使用它们

  • Scanner - identify the scanner methods you used and why

Scanner - 确定您使用的Scanner方法以及为什么使用它们

  • if statements – document any if statements you used and how they support decisions.

if语句 - 记录您使用的任何if语句以及它们如何支持决策。

  • You also need to include at least 1 screen shot of your code being testing on the object bench.

您还需要至少包括一张屏幕截图,显示您在对象测试台上对代码进行测试的情况。

Please double check your code compiles and your submission document contains the updated version of all code prior to submission.

在提交之前,请仔细检查您的代码是否编译,并确保提交文档包含先前所有代码的更新版本。

SUBMISSION

提交

You will submit your assessment in MS Word document format – yourName-studNo.doc. The document will have 3 sections:

您需要以MS Word文档格式提交您的评估 - yourName-studNo.doc。该文档将包含三个部分:

  • The scenario: You will write the back story for your program – this will be assessed using LLO minimum 100 words

情景:您将编写程序的背景故事 - 这将使用LLO进行评估,最少需要100个单词。

demo

情境:您需要为您的程序编写一个背景故事 - 这将使用LLO最少100个单词进行评估。

在这个程序中,我选择了两个我最喜欢的事物 - 一本书和一款游戏。这本书是一部科幻小说,描述了一群宇航员在太空中的冒险之旅,他们遇到了许多困难和危险,但最终成功地回到了地球。而这款游戏是一款经典的角色扮演游戏,讲述了一个勇敢的英雄拯救王国的故事。

为了实现这个程序,我将创建两个类,一个代表这本书,一个代表这款游戏。对于每个类,我将选择一些属性,例如书的作者、出版商、出版日期以及游戏的名称、发行商、发行日期等。我还将编写访问器和修改器方法,以便能够更改这些属性。此外,我将编写一个备用构造函数,以便于创建对象。

在我的主类中,我将使用Scanner对象来让用户输入一些信息,以修改这两个对象。例如,用户可以输入新的书名或游戏名称。在适当的情况下,我将使用if语句来处理用户的响应,以实现一些决策。

我的目标是展示我的面向对象编程技能,并向其他人展示我最喜欢的书和游戏。

  • The Code: You will copy the code from your BlueJ project into this section

代码:您将从BlueJ项目中复制代码到此部分。

  • The explanation: you will explain your code choices and reasoning. You also need to include at least one screenshot of testing your code. Include any issues you had and how you resolved them. Minimum 300 words.

解释:您将解释您的代码选择和推理。您还需要至少包括一个测试代码的截图。包括任何问题以及您如何解决这些问题。最少需要300个单词。

demo

我的程序将涉及两个不同的类,分别是“汽车”和“猫”。对于“汽车”类,我选择了三个属性,分别是“型号”(String类型)、“价格”(double类型)和“是否已售”(boolean类型),我认为这些是一个汽车最基本的属性。对于“猫”类,我选择了“姓名”(String类型)、“年龄”(int类型)和“是否已绝育”(boolean类型),这些也是猫最基本的属性。我还在“汽车”类中添加了一个常量,表示汽车的最大速度。

我设计了两个构造函数,一个是默认构造函数,另一个是带参数的构造函数。默认构造函数将初始化所有属性,并为布尔类型属性设置初始值。带参数的构造函数将根据输入参数设置属性。

我为每个属性创建了访问器和修改器方法,以便可以在需要时读取和更改属性的值。

我还为每个类实现了一个toString()方法,用于将类的属性以特定的格式显示出来。

在主类中,我创建了一个Scanner对象作为局部变量,并使用默认构造函数创建了一个汽车对象和一个猫对象。然后,我在控制台上使用toString()方法显示了这两个对象的属性。

接下来,我要求用户输入汽车价格和猫的名字,并使用相应的修改器方法更新汽车和猫的属性。我还使用if语句根据用户输入来判断汽车是否已经出售,并相应地更新汽车的属性。

在测试过程中,我遇到了一些问题,主要是代码中的语法错误和类型不匹配。我通过检查代码和调试来解决这些问题,并最终成功地运行了程序。以下是一个我在对象测试台上测试程序的截图:

测试代码截图
测试代码截图

在编写代码的过程中,我尽量保持代码的简洁和清晰,以便易于阅读和理解。我还使用了适当的访问修饰符来控制属性和方法的可见性。最终,我完成了任务并满足了评估的所有要求。

The deadline for submission of this project is Friday 11:59pm in week 6.

这个项目的提交截止时间是第六周星期五晚上11:59。

Draft Project idea: due Friday 11:59pm Week 4 for tutor approval

项目想法草稿:需在第四周星期五晚上11:59前提交以供导师批准。

Draft Project A: due Tutorial B Week 6 – draft code review by tutor

草稿项目A:需在第六周B教学辅导课提交 - 经导师审查的草稿代码审查

All projects submitted after the deadline will incur late penalties of 1 grade band every 2 days (or part thereof).

所有在截止日期之后提交的项目都将产生延迟惩罚,每2天(或其一部分)降低1个等级段。

CRITERIA
标准
WEIGHT
权重
SLOs / LLOs
学习目标(SLOs)/学习成果(LLOs)
PLOs
专业学习成果(PLOs)
Demonstrate a working knowledge of basic Java code
展示基本Java代码的工作知识。
40%1, 2A1, A3, E1
公众号:AI悦创【二维码】

AI悦创·编程一对一

AI悦创·推出辅导班啦,包括「Python 语言辅导班、C++ 辅导班、java 辅导班、算法/数据结构辅导班、少儿编程、pygame 游戏开发、Web、Linux」,全部都是一对一教学:一对一辅导 + 一对一答疑 + 布置作业 + 项目实践等。当然,还有线下线上摄影课程、Photoshop、Premiere 一对一教学、QQ、微信在线,随时响应!微信:Jiabcdefh

C++ 信息奥赛题解,长期更新!长期招收一对一中小学信息奥赛集训,莆田、厦门地区有机会线下上门,其他地区线上。微信:Jiabcdefh

方法一:QQopen in new window

方法二:微信:Jiabcdefh

上次编辑于:
贡献者: AndersonHJB
你认为这篇文章怎么样?
  • 0
  • 0
  • 0
  • 0
  • 0
  • 0
评论
  • 按正序
  • 按倒序
  • 按热度