首页 > > 详细

Java辅导 Java Assignment讲解Java程序、Java讲解


Introduction
Requirement
1: Oxo
This assignment counts for 20% of the assessment for the unit. The
main aim in this assignment is to create a multi-class program, to
practice design, classes, objects, libraries, unit testing, and style.
The program
The idea is to write a program called Oxo.java which allows two
people to play the game Noughts and Crosses (or Tic-Tac-Toe if you
are American) using just text. It would be reasonably easy to write
this program in one piece, but you are asked to deliberately over-
engineer it, as if it were a bigger project, to show off your object
oriented skills. Here are some suggested classes:
• A Tester class to support unit testing. A Tester object has
the is method that we have been using already, and keeps a
count of the number of tests. You can also add an extra method,
called when testing is over, to print the number of tests passed.
• A Position class to represent a position on the 3x3 playing
board.
• An enumerated type class, or some other way to represent the
possible values that can appear on the board (an X, an O, or
blank) in a symbolic way.
• A Board class, to represent the current state of the game, i.e. a
3x3 grid, plus which player’s turn it is to move next. It should
probably also be responsible for checking whether moves are
valid or not, whether a player has just won or not, or whether the
game is a draw.
• A Display class, which deals with printing out the board as text,
and with receiving inputs from the players
• An Oxo class which controls everything
A board might be printed out like this (or something similar which
indicates row letters and column numbers):
123
a OX.
b ..X
c …
The two players might use the same keyboard to type in moves:
Player O’s move: b2
Some things you might like to know, and which might be helpful, are:
• You can use System.out.print to print out text without a
newline, e.g. as a prompt
• You can put import java.util.; at the top of your program
to import a helpful collection of utility classes, and/or import
java.io.; for input/output classes
• Either the Scanner or Console class can be used to help with
reading lines of text from the user
Assessment
Some things which I am looking for are: good design (probably along
the lines I have suggested, but in any case with “the right code in the
right place”), good style. (DRY, consistent, commented code), no
statics (except for main methods and unit testing), private fields
(except maybe for immutable objects), defensive programming (i.e.
testing for bad things even though they shouldn’t happen, to improve
debugging), unit testing (to convince me that your classes do what
they should), robustness (to convince me that your classes don’t do
what they shouldn’t).
Bearing in mind that the official allowance for the assignment is only
5 hours, you have plenty to do, and doing it well will probably get you
a mark in the 60-70 range. But if you are clever, or quick, or bored, or
want extra marks, you could try one of these extensions. Implement
an interesting variant of the game. Add graphics. Add networking to
play on two different computers. Add an AI component, so a human
can play against the computer.
Submission
Just submit your .java files (I expect to be able to compile them).
Add a readme.txt/readme.md/readme.pdf file if there is
anything about your program which isn’t immediately obvious or you
have other comments to make.
2: Graphics
This assignment counts for 40% of the unit, and late submission
results in mark penalties.
The aim of this assignment is to get to grips with Java’s graphics
library facilities, to demonstrate the design and programming skills
which you have acquired from the course, and to show off some
creativity.
Your task is to create any Java program you like which has a
graphical user interface, and shows off Java’s graphics facilities in
some way. Your program could be a pet project you’ve wanted to
have a go at for some time, or it could be a game or other interesting
or useful application. It is deliberately completely open ended, to give
you creative freedom.
Since Java’s graphics facilities are extensive, you are not expected to
cover them all. You may want to concentrate on the layout of a
conventional graphical user interface using widgets such as buttons
and menus and so on. Alternatively, you may want to concentrate on
drawing issues such as sketching or drag-and-drop. Or perhaps you
could investigate the support for handling or manipulating images. If
your interests are in the area of user interaction, then a game might
suit you well. Or if you have strong non-graphical interests, you may
want to concentrate on developing something interesting where the
graphical interface is relatively incidental and simple. If you want to
experiment with libraries beyond the standard ones (e.g. 3-D) or if
you want to write an Android app to gain experience in that area,
that’s OK too, but please avoid web applets since they are essentially
obsolete now.
You can name your program anything you want, but I don’t
recommend calling it Graphics.java because that is likely to clash
with the Graphics library class. You can either take on something
relatively simple and polish it well, or try something more ambitious
and submit a proof-of-concept prototype. If you produce a normal
application, packaging it as an executable jar file would be
convenient. In any case, it is a good idea to submit a zip or jar file
with all the source code and resources such as images in it, plus
instructions or a make or ant file to tell me how to build and run the
program.
As well as the program, you should produce a report
(report.pdf or report.txt or report.html) which explains the
design of your program, tells me about your experiences in
developing it, and points out any features which I might otherwise
miss. Also mention any external library that you used, and include a
link in the report to the website where it was downloaded from. You
should also acknowledge any code which you copied or adapted
(beyond simple examples from tutorials) and any IDE or other
development tools which you used.

 

联系我们
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 99515681 微信:codinghelp
程序辅导网!