首页
编程语言
数据库
网络开发
Algorithm算法
移动开发
系统相关
金融统计
人工智能
其他
首页
>
> 详细
讲解CS 340、讲解Software Design、辅导Python/c++编程语言、辅导c/c++,Java 讲解Java程序|辅导留学生
Software Design III (CS 340), Spring 2019
Assignment 01 (40 points)
Due by 5:00 PM, Friday, 15 February 2019
1 Word-Search Puzzle (20 points)
For this assignment, you will be using the provided WordPuzzle class. This class is almost entirely
complete. When its main() method is executed, it will open up a window, featuring a single button;
when that button is pressed a file-chooser dialogue window will open, allowing the user to select a
text-file. Once a file is chosen, the program calls the solve() method, with the file as input.
Your job is to implement a new class, called WordPuzzleSolver. This new class must implement
the provided interface, PuzzleSolver, which means:
There will be a public method, readFile(), that takes in a file as input. This method must
be called so that the implementing class knows which file it will use to read in the data about
the puzzle it needs to solve. (It will not solve the puzzle yet, that will come later). Exactly
how this method works is up to you.
There will be a public method, solvePuzzle(), that solves the puzzle contained in the file
that was sent as input to the previous method. Thus, this method will only work if the
previous method has already been called, with a proper puzzle file as input (the format of
puzzle files, and of correct output, is described below).
Back in the WordPuzzle class, you will complete the solve() method so that when called it
creates an instance of your new solver class, sends in the input file, and calls the two methods
just described to solve the puzzle and print results.
A puzzle file is simply a text-file. The first line consists of two positive integers, giving the number
of rows and number of columns, respectively, of a word-search puzzle. Following that will be a
block of text of the given size (you can assume that the input is in the right format). After that
block of text, there will be one or more words, each on a single line. As an example, the following
specifies a (5 × 6) puzzle grid, along with 4 words for which to search:
5 6
turtle
waterb
elofem
evodek
pckrse
turtle
dove
packers
fee
1Your program will read in the grid of letters (using any data-structures you choose). It will
then proceed through the list of words, one at a time, in order. For each word, it will search the
grid for that word, looking up, down, left, right, and diagonally. Words can run in any of the 8
possible directions, and cannot skip any letters, or run off the sides of the grid. For each word that
can be found, the program will report that fact, using the exact format:
"
" was found at row
, column
, going
.
where the row-number and column-number are given as the starting position (first character) of the
word, counting from the top of the grid of characters, left-to-right, and starting at 0, as in an array
or String. The direction reported will be one of the following, depending upon what direction the
word can be found: U, D, R, L, UR, UL, DR, DL (up, down, left, right, up-right, up-left, down-right,
down-left). You can assume that each word occurs at most one time in the grid, so that if the word
can be found, the output will be unique. When a word is not found anywhere in the grid, that will
also be reported, using the exact format:
"
" was not found.
For the example puzzle shown on the previous page, then, the correct output would be as follows:
"turtle" was found at row 0, column 0, going R.
"dove" was found at row 3, column 3, going L.
"packers" was not found.
"fee" was found at row 2, column 3, going DR.
Note 01: the assignment download includes two sample word-puzzle files, along with a file that
shows the correct output for each input file. For full points, your code should produce exactly the
same output for these sample files.
Note 02: your code should be able to handle any input file that it is given, so long as that file is
in the basic format described. When grading the work, I will be testing your code using files of my
own. If you want to make more puzzle files for de-bugging and testing purposes, feel free to do so.
You can create any such files you need using a simple text editor.
22 Assembly Language Simulator (20 points)
For this part of the assignment, you will be creating a program that simulates a very simple
computing system. Your program will read in files consisting of code in a simple version of assembly
language (that is, a simple set of basic instructions to follow); it will then simulate execution of
that code, printing out the results at the end.
You should begin by creating a new class, called Assembler. This code should do the same thing
as the WordPuzzle class for the first part of the assignment. That is, it should create a window
with a button and label, and allow the user to choose text-files to open (feel free to cut and paste
from the other class, making whatever changes needed). Once your code opens up a file chosen by
the user, it should send that file for processing by another class (with whatever name you choose).
That other class is where you will implement the simulation of the assembly language processor.
The system you are simulating has the following features:
1. It has two registers, A and B, each of which is a memory location that is capable of storing a
non-negative integer value (that is, a number n such that 0 ≤ n ≤ Integer.MAX_VALUE). At
the start of the execution of any program, each register starts off at zero (0).
2. A program is read from a text-file. Each line consists of one of the following instructions:
ADD: this command adds a number to one of the registers; it takes the name of the register,
along with an integer value to add, as arguments. For example, the command ADD A 3
adds 3 to the value currently stored in register A; the command ADD B -2 subtracts 2
from the value of register B (by adding 2). Remember that registers can only handle
positive integer values; thus, any subtraction that would make the register value negative
in fact only makes it hold the value 0. Similarly, any addition that would make the value
too large has the effect that the register holds maximal value (Integer.MAX_VALUE).
INC: this command increments the register that is named as an argument. For instance,
the command INC A increments register A. The command behaves as if it were identical
to ADD A 1, which means that if register A is already at the maximum possible value,
executing INC A has no effect.
JIG: this command executes a conditional jump in the code by comparing the two registers;
it takes the names of the two registers, in some order, along with an integer value,
as arguments. When executed, it checks whether the value in the first named register is
greater than or equal to the value of the second named register, and if so moves forwards
or backwards by the number of lines given as the last argument. Thus, the command
JIG A B 2 checks if the value of register A ≥ the value of register B, and if so moves 2
lines forward. The command JIG B A -1 checks if the value of B ≥ the value of A, and
if so moves 1 line back in the code.
SET: this command sets a named register to a given integer value. Thus, the command
SET A 4 sets the value of register A to 4. You can assume that the integer value given
is always in the possible range for any register.
3. Unless the program executes a conditional jump forward or back, it proceeds in an imperative
sequence, one line at a time. Execution terminates either when the program reaches the end
of the file, or when it executes a jump that causes it to move to a position that is outside of
3the bounds of the program. That is, if we are at the second line of a 3-line program, then a
jump forward or backwards 2 or more lines will cause the program to terminate.
As an example, consider the following program:
INC A
JIG A B 2
INC B
INC A
When this code executes, it starts with both registers set to 0, as always. The first line then
increments register A to 1. At the second line, it checks whether the value of A ≥ the value of B,
and since it now is, it jumps forward 2 lines, to the last line of code. That line then increments
register A once again, to value 2, and the program terminates.
Your program will simulate this process. When the program terminates, it will produce a single
line of output, giving the final values of the two registers, in the exact format:
RESULT => A:
, B:
.
That is, for the example program shown above, the output will be:
RESULT => A: 2, B: 0.
Note: as before, your code must handle any program in the given format, and will be tested on
files beyond the two that are included with the assignment download. You can assume that every
program will eventually terminate in a finite number of steps.
Handing in your work: you will hand in your code via D2L. Your work should consist of a
single compressed folder containing all of your source code, for both parts of the assignment. Files
should be named as specified in this document, where required. The class website contains more
information about preparing compressed documents if you need a refresher on that.
Coding conventions: Each part of the program has a points total, given above. For full points,
you should complete all those components, and observe the basic coding conventions as follows:
Comments should appear at the start of any code-file you write or change, with your name,
the date of your work, and a short explanation of what the code does.
Each method should be preceded by a blank line, followed by at least one line of comments
explaining what the method does.
Methods should be private if possible, and public only if necessary.
Class variables should be local to methods if possible, and should only appear as global
variables if they appear in more than one method of the class.
Unless absolutely necessary, global instance variables should be private.
4 Code can be broken up by blank lines, but keep this to a low level. There should be no more
than a single blank line separating pieces of code. Within a line of code, white space should
not be too wide, for clarity.
Code should be properly indented and separated into lines.
Standard naming conventions (capitalized class names, lower-case method/variable names,
etc.) should be followed.
联系我们
QQ:99515681
邮箱:99515681@qq.com
工作时间:8:00-21:00
微信:codinghelp
热点文章
更多
辅导 cs1b spring 2024 tth hw...
2024-04-19
讲解 managing financial risk...
2024-04-19
辅导 cs 0449 – project 5: /...
2024-04-19
辅导 elec 2141 digital circu...
2024-04-19
讲解 csc171 — videogame pro...
2024-04-19
讲解 comp3411 artificial int...
2024-04-19
讲解 stat3061: random proces...
2024-04-19
辅导 accounting 452, spring ...
2024-04-19
辅导 finc5001 foundations in...
2024-04-19
辅导 7ssmm712 – topics in a...
2024-04-19
讲解 com 337 - film studies ...
2024-04-19
辅导 mes202tc - digital vlsi...
2024-04-19
辅导 geography 2041b distanc...
2024-04-19
辅导 ecos3006 international ...
2024-04-19
讲解 fit5225 2024 sm1 creati...
2024-04-19
讲解 cit 593: introduction t...
2024-04-19
讲解 math 4931: take home ex...
2024-04-19
辅导 csci 547|info 533: syst...
2024-04-19
辅导 cs536-s24 intro to pls ...
2024-04-19
讲解 fit5212 - assignment 1辅...
2024-04-19
热点标签
ecmt1010
engg1340
fit5216
cmpsc311
econ3208
basc0003
ee3121
acct2002
comp5313
busi2131
ise529
elec372/472
csit940/csit440
cenv6141
comp3027/comp3927
ftec5580
comp1433
msci223
mark203
en3098
eden1000
ece6483
econ4410
mats16302
com6521
can202
cs 6476
chc6186
comp3211
comp222
csc1002
comp10002
cs 161
comp282
swen20003
comp27112
comm1190
elec9764
acfi3308
acct7101
fin6035
comp2048
geog0163
comp2013
coen 146
dts101tc
comp4880/8880
cs 455
07
sehh2042
comp30023
stat0045.
fil-30023
celen085
psyc40005
math40082
are271
comp9311
ee5311
imse2113
comp 2322
acct2102
fnd109
int102
is3s664
is6153
data4000
accfin5034
fit5212
cs536-s24
fit5225
ecos3006
mes202tc
finc5001
stat3061
csc171
cs1b
7ssmm712
bu.450.760
comp3411
cs170
swen90004
cpt206
comp5313/comp4313—large
bl5611
kxo206
comp532
elec207
kxo151
cs 2820
cpt108
math2319
dts204tc
qm222
comp2511
ccs599
infs1001
mat2355
eeee4123
25721
ifn647
pols0010
hpm 573
cs 2550
comp9417
stat0023
csci 1100
qbus6860
comp2003j
cse340
cs 61b
cs360
fin 3080
ierg 4080
cs6238
cit 594
finm7406
hw6
elec9713
asb-2522
mso3610
lit301
mcd4540
geog0030
125.330
biol0006
125.320
cs3334
fit2093
acct1101
110.309
masy1-gc
cs314
elec0048
gds104
mg5637
fit2096
math5905
eel4837
sehs4515
cpt s 321
asb2522 investment
ma214
co2104
mgmt2015
32516
math32051
econ1012
mark2052
comp3310
econ0019
dsci 525
abmf3184
aps106
antc27
finm7401
itp122
tech2300
math3026
is2022
cao107
36318
cs 211
comp9024
fit1047
ics4u
2xc3
en.540.635
4qqmn506
finn3081
phys10362
sta601
ec481e
math5165
csi 2120
el1205
comp7250
ecos3013
beam065
info1113
comp2051
csc325
mne 6130
ai6126
inu1111
ecs150
is61x6
cse115
seng6110
bus265
cpts260
mphy0009
csc306
eco2011
ee3004
st332
idepg001
info6001
cpt106
finm7409
联系我们
- QQ: 99515681 微信:codinghelp
© 2024
www.7daixie.com
站长地图
程序辅导网!