CSSE7023讲解 、Java设计程序辅导
Advanced Software Engineering (CSSE7023)
Assignment 1 — Semester 1, 2024
School of EECS
The University of Queensland
Due March 28th 16:00 AEST
One must learn by doing the thing; for though you think you
know it, you have no certainty, until you try.
— Sophocles
Do not distribute. Revision 1.0.0
Overview This assignment delivers practical experience developing a Java project based on a supplied specification. The specification is provided in the form of JavaDocs, which describe the classes and interfaces that
your assignment must implement. You will be assessed on your ability to
• implement a program that complies with the specification,
• and develop code that conforms to the style conventions of the course.
Task Spreadsheet applications are powerful programs that combine data and formulae to perform calculations.
In this assignment, you will be implementing SheeP (Sheet Processor), a spreadsheet application. SheeP
is similar to Google Sheets or Microsoft Excel. It consists of a grid of cells , each of which contains either data
or a formula. The formulae can reference other cells in the grid to use their values. Formulae are evaluated to
produce a value for the cell. A cell is updated whenever the data or formulae in any cell it references changes.
Common Mistakes Please carefully read Appendix A. It outlines common and critical mistakes which you
must avoid to prevent a loss of marks. If at any point you are even slightly unsure, please check as soon as
possible with course staff.
Plagiarism All work on this assignment is to be your own individual work. By submitting the assignment
you are claiming it is entirely your own work. You may discuss the overall general design of the application
with other students. Describing details of how you implement your design with another student is considered
to be collusion and will be counted as plagiarism.
You may not copy fragments of code that you find on the Internet to use in your assignment. Code supplied
by course staff (from this semester) is acceptable, but must be clearly acknowledged as described in the next
paragraph.
You may find ideas of how to solve problems in the assignment through external resources (e.g. StackOverflow, textbooks, ...). If you use these ideas in designing your solution you must cite them. To cite a resource,
provide the full bibliographic reference for the resource in file called refs.md. The refs.md file must be in the
root folder of your project. For example:
1 > cat refs.md
2 [1] E. W. Dijkstra, "Go To Statement Considered Harmful," _Communications of the ACM_,
3 vol 11 no. 3, pp 147-148, Mar. 1968. Accessed: Mar. 6, 2024. [Online]. Available:
4 https://www.cs.utexas.edu/users/EWD/transcriptions/EWD02xx/EWD215.html
© The University of Queensland 2024 Page 1
5 [2] B. Liskov and J. V. Guttag, _Program development in Java: abstraction,
6 specification, and object-oriented design_. Boston: Addison-Wesley, 2001.
7 [3] T. Hawtin, "String concatenation: concat() vs '+' operator," stackoverflow.com,
8 Sep. 6, 2008. Accessed: Mar. 8, 2024. Available:
9 https://stackoverflow.com/questions/47605/string-concatenation-concat-vs-operator
10 >
In the code where you use the idea, cite the reference in a comment. For example:
1 /**
2 * What method1 does.
3 * [1] Used a method to avoid gotos in my logic.
4 * [2] Algorithm based on section 6.4.
5 */
6 public void method1() ...
8 /**
9 * What method2 does.
10 */
11 public void method2() {
12 System.out.println("Some " + "content.") // [3] String concatenation using + operator.
13 }
You must be familiar with the university’s policy on plagiarism.
https://uq.mu/rl553
If you have questions about what is acceptable, please ask course staff.
Generative Artificial Intelligence You are required to implement your solution on your own, without the
use of generative artificial intelligence (AI) tools (e.g. ChatGPT or Copilot). This is a learning exercise and
you will harm your learning if you use AI tools inappropriately. Remember, you will be required to write code,
by hand, in the final exam.
Specification
The specification document is provided in the form of JavaDocs.
◦ Implement the classes and interfaces exactly as described in the JavaDocs.
◦ Read the JavaDocs carefully and understand the specification before programming.
◦ Do not change the public specification in any way, including changing the names of, or adding additional,
public classes, interfaces, methods, or fields.
◦ You are encouraged to add additional private members, classes, or interfaces as you see fit.
You can download the JavaDoc specification from BlackBoard (Assessment → Assignment One) or access it at
the link below.
https://csse7023.uqcloud.net/assessment/assign1/docs/
Getting Started
To get started, download the provided code from BlackBoard (Assessment → Assignment One). This archive
includes code for the GUI components. Extract the archive in a directory and open it with IntelliJ.
Task
Implement each of the classes and interfaces described in the JavaDoc specification.
© The University of Queensland 2024 Page 2
Figure 1: Class diagram of the specification for assignment 1.
Project Overview
sheep.core This package contains the interface between the model of a spreadsheet and the user interface.
Implementations of the SheetView interface tell the interface how to render a spreadsheet and communicate this information via the ViewElement object.
Implementations of the SheetUpdate interface handle user updates to the spreadsheet and provide the
result of the update via a UpdateResponse object.
sheep.sheets This package contains implementations of the SheetView and SheetUpdate interfaces and other
supporting classes. Primarily it implements three different types of spreadsheets: FixedSheet, DisplaySheet,
and Sheet.
sheep.expression Within a spreadsheet, the value at a particular cell is represented by an expression. This
package stores the Expression interface that all expressions must implement.
Expressions are constructed via expression factories that implement the ExpressionFactory interface,
e.g. CoreFactory.
This package also stores relevant exceptions.
sheep.expression.basic This package stores core expression implementations, namely, the empty cell, Nothing,
a constant number value, Constant, and a reference to another cell, Reference.
sheep.expression.arithmetic Arithmetic expressions are contained in this package. All arithmetic expressions are subclasses of the abstract class Arithmetic.
sheep.parsing A parser accepts string input and constructs an appropriate expression. For example, given
the string “5”, a parser would construct an instance of the Constant expression that represents 5.
All parsers implement the Parser interface. If a parser cannot parse a string, a ParseException is
thrown.
sheep.fun Provided classes that pre-load spreadsheets with test data, such as the Fibonacci sequence using
the Fibonacci class.
sheep.ui Provided implementation of the user interface.
Stages
Software of any reasonable size or complexity should be developed in stages. This technique is called incremental
development. It allows you to determine that your logical approach is working and that you can implement a
working solution. In professional software development, it allows you to get feedback from clients as you develop
the system. This contrasts with a “big bang” approach of taking months or years to develop the entire system,
and then showing it to clients to find out that it does not do what they want.
The assignment is decomposed into stages to encourage incremental development. You should finish each
stage before moving on to the next . The provided Main class allows you to run each stage individually by
uncommenting the appropriate lines in the main method. Figure 1 highlights the classes that you will implement
in each stage: green for stage 0, blue for stage 1, yellow for stage 2, and purple for provided code. At each
stage, ensure that you thoroughly test your implementation.
Stage 0 Create a simple implementation of a spreadsheet, FixedSheet. The FixedSheet class must be
within the sheep.sheets package and implement the sheep.core.SheetView and sheep.core.SheepUpdate
interfaces. After implementing the FixedSheet class and uncommenting the appropriate lines in the main
method, the program should display as below when executed.
© The University of Queensland 2024 Page 4
Stage 1 Implement the basic types of expressions within the spreadsheet: constant values, references to
other cells, and empty cells. Create an expression factory to create these expressions and a parser to parse
expressions from strings. Finally create DisplaySheet to show the results of these expressions. When
the appropriate lines in the main method are commented out, the program should display as below when
executed.
Stage 2 Complete the implementation of expressions to include arithmetic operations. Your parser and
expression factory should be able to parse and create these expressions. Create the full Sheet implementation, this sheet should appropriately update cells when other cells change. When the appropriate lines
in the main method are commented out, the program should display as below when executed.
Grading
Three aspects of your solution will considered in grading your submission. These are functionality, automated
style check, and human readable style.
Functionality Each class has a number of unit tests associated with it. Your grade for functionality is based
on the percentage of unit tests you pass. Classes may be weighted differently depending on their complexity.
© The University of Queensland 2024 Page 5
Automated Style Check Your grade for automated style checking is based on the percentage of style
violations identified by the Checkstyle tool1
. Multiple style violations of the same type will each be counted
when calculating the percentage of style violations.
Note: There is a plug-in available for IntelliJ that will highlight style violations in your code. Instructions for
installing this plug-in are available in the Java Programming Style Guide on BlackBoard (Learning Resources →
Guides). If you correctly use the plug-in and follow the style requirements, it should be relatively straightforward
to get high marks for this section.
Human Readable Style Course staff will mark the readability of the code you submit. This will assess the
structure, style, documentation and logic of your code. The high-level evaluation is how easily can another
programmer, who is familiar with Java, understand your code. This includes layout of code, use of descriptive
identifier names, and concise and informative comments. It also includes the detailed design of your code’s logic
and how much code is unnecessarily duplicated.
Automated Testing & Checking
Marking will be done automatically in a Linux environment. The environment will not be running Windows,
and neither IntelliJ nor Eclipse (or any other IDE) will be involved. OpenJDK 21 with the JUnit 4 library will
be used to compile and execute your code. IDEs like IntelliJ provide code completion hints. When importing
Java libraries they may suggest libraries that are not part of the standard library. These will not be available in
the test environment and your code will not compile. When uploading your assignment to Gradescope, ensure
that Gradescope says that your submission was compiled successfully.
Your code must compile.
If your submission does not compile, you will receive zero marks.
Submission
Submission is via Gradescope. Submit your code to Gradescope early and often. Gradescope will give you some
feedback on your code, but it is not a substitute for testing your code yourself.
What to Submit Your submission must have the following internal structure:
src/ folders (packages) and .java files for classes described in the JavaDoc.
A complete submission would look like:
1The latest version of the course Checkstyle configuration can be found at http://csse7023.uqcloud.net/checkstyle.xml. See
the Style Guide for instructions.
© The University of Queensland 2024 Page 6
src/sheep/expression/ExpressionFactory.java
src/sheep/expression/InvalidExpression.java
src/sheep/expression/Expression.java
src/sheep/expression/TypeError.java
src/sheep/expression/CoreFactory.java
src/sheep/expression/basic/Reference.java
src/sheep/expression/basic/Constant.java
src/sheep/expression/basic/Nothing.java
src/sheep/expression/arithmetic/Arithmetic.java
src/sheep/expression/arithmetic/Equal.java
src/sheep/expression/arithmetic/Divide.java
src/sheep/expression/arithmetic/Less.java
src/sheep/expression/arithmetic/Plus.java
src/sheep/expression/arithmetic/Minus.java
src/sheep/expression/arithmetic/Times.java
src/sheep/sheets/DisplaySheet.java
src/sheep/sheets/CellLocation.java
src/sheep/sheets/Sheet.java
src/sheep/sheets/FixedSheet.java
src/sheep/sheets/SheetBuilder.java
src/sheep/parsing/Parser.java
src/sheep/parsing/ParseException.java
src/sheep/parsing/SimpleParser.java
refs.md
Ensure that your classes and interfaces correctly declare the package they are within. For example,
Reference.java should declare package sheep.expression.basic;.
Only submit the src folder and the refs.md file in the root directory of your project.
Do not submit any other files (e.g. no .class files or IDE files).
Provided tests A small number of the unit tests (about 10-20%) used for assessing functionality will be
provided in Gradescope. These will be used to test your submission, each time you upload it.
These are meant to provide you with an opportunity to receive feedback on whether the basic functionality of
your classes works correctly or not. Passing all the provided unit tests does not guarantee that you will pass
all the tests used for functionality marking.
Assessment Policy
Late Submission You must submit your code before the deadline. Code that is submitted after the deadline
will receive a late penalty as described in section 5.3 of the course profile. The submission time is determined
by the time recorded on the Gradescope server. A submission is not recorded as being received until uploading
your files completes. Attempting to submit at the last minute may result in a late submission.
You may submit your assignment to Gradescope as many times as you wish before the due date. There will be
two submission links on Gradescope, one for “on-time” submissions and one for “late” submissions. If you have
an extension for the assignment, you will submit your assignment via the “late” submissions link. Your last
submission made to the “on-time” submission link, before the due date, will be the one that is marked, unless
you make a submission to the “late” submission link. If a misconduct case is raised about your submission, a
history of regular submissions to Gradescope, which demonstrate progress on your solution, could support your
argument that the work was your own.
© The University of Queensland 2024 Page 7
A CRITICAL MISTAKES
You are strongly encouraged to submit your assignment on time, or by the revised deadline if you have an
extension. Experience has demonstrated that most students who submit their assignments late lose more marks
due to the late penalties than they gain by making improvements to their work.
Extensions If an unavoidable disruption occurs (e.g. illness, family crisis, etc.) you should consider applying
for an extension. Please refer to the following page for further information.
https://uq.mu/rl551
All requests for extensions must be made via my.UQ, before the submission deadline. Do not email the course
coordinator or other course staff to request an extension.
Remarking If an administrative error has been made in the marking of your assignment (e.g. marks were
incorrectly added up), please contact the course coordinator (csse7023@uq.edu.au) to request this be fixed. For
all other cases, please refer to the following page for further information.
https://uq.mu/rl552
Change Log Revision: 1.0.0
If it becomes necessary to correct or clarify the task sheet or JavaDoc, a new version will be issued and an
announcement will be made on the course Blackboard site. All changes will be listed in this section of the task
sheet.
A Critical Mistakes
THINGS YOU MUST AVOID
This is being heavily emphasised here because these are critical mistakes which must be avoided.
Code may run fine locally on your own computer in IntelliJ, but it is required that it also builds and runs
correctly when it is marked with the electronic marking tool in Gradescope. Your solution needs to conform to
the specification for this to occur.
• Files must be in the correct directories (exactly) as specified by the JavaDoc. If files are in incorrect
directories (even slightly wrong), you may lose marks for functionality in these files because the implementation does not conform to the specification.
• Files must have the correct package declaration at the top of every file. If files have incorrect package
declarations (even slightly wrong, such as incorrect capitalisation), you may lose marks for functionality
in these files because the implementation does not conform to the specification.
• You must implement the public and protected members exactly as described in the supplied documentation (no extra public/protected members or classes). Creating public or protected data members in a
class when it is not specified will result in loss of marks, because the implementation does not conform to
the specification.
◦ You are encouraged to create private members as you see fit to implement the required functionality
or improve the design of your solution.
• Do not import the org.junit.jupiter.api package. This is from JUnit 5 and may cause our JUnit
tests to fail.
• Do not use any version of Java other than 21 when writing your solution. If you accidentally use Java
features which are different in a version older than 21, then your submission may fail functionality tests. If
you accidentally use Java features which are only present in a version newer than 21, then your submission
may fail to compile.
© The University of Queensland 2024 Page 8