首页
编程语言
数据库
网络开发
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
热点文章
更多
mgt202辅导 、讲解 java/pytho...
2025-06-28
讲解 pbt205—project-based l...
2025-06-28
辅导 comp3702 artificial int...
2025-06-28
辅导 cs3214 fall 2022 projec...
2025-06-28
辅导 turnitin assignment讲解...
2025-06-28
辅导 finite element modellin...
2025-06-28
讲解 stat3600 linear statist...
2025-06-28
辅导 problem set #3讲解 matl...
2025-06-28
讲解 elen90066 embedded syst...
2025-06-28
讲解 automatic counting of d...
2025-06-28
讲解 ct60a9602 functional pr...
2025-06-28
辅导 stat3600 linear statist...
2025-06-28
辅导 csci 1110: assignment 2...
2025-06-28
辅导 geography调试r语言
2025-06-28
辅导 introduction to informa...
2025-06-28
辅导 envir 100: introduction...
2025-06-28
辅导 assessment 3 - individu...
2025-06-28
讲解 laboratory 1讲解 留学生...
2025-06-28
辅导 ct60a9600 renewable ene...
2025-06-28
辅导 economics 140a homework...
2025-06-28
热点标签
mktg2509
csci 2600
38170
lng302
csse3010
phas3226
77938
arch1162
engn4536/engn6536
acx5903
comp151101
phl245
cse12
comp9312
stat3016/6016
phas0038
comp2140
6qqmb312
xjco3011
rest0005
ematm0051
5qqmn219
lubs5062m
eee8155
cege0100
eap033
artd1109
mat246
etc3430
ecmm462
mis102
inft6800
ddes9903
comp6521
comp9517
comp3331/9331
comp4337
comp6008
comp9414
bu.231.790.81
man00150m
csb352h
math1041
eengm4100
isys1002
08
6057cem
mktg3504
mthm036
mtrx1701
mth3241
eeee3086
cmp-7038b
cmp-7000a
ints4010
econ2151
infs5710
fins5516
fin3309
fins5510
gsoe9340
math2007
math2036
soee5010
mark3088
infs3605
elec9714
comp2271
ma214
comp2211
infs3604
600426
sit254
acct3091
bbt405
msin0116
com107/com113
mark5826
sit120
comp9021
eco2101
eeen40700
cs253
ece3114
ecmm447
chns3000
math377
itd102
comp9444
comp(2041|9044)
econ0060
econ7230
mgt001371
ecs-323
cs6250
mgdi60012
mdia2012
comm221001
comm5000
ma1008
engl642
econ241
com333
math367
mis201
nbs-7041x
meek16104
econ2003
comm1190
mbas902
comp-1027
dpst1091
comp7315
eppd1033
m06
ee3025
msci231
bb113/bbs1063
fc709
comp3425
comp9417
econ42915
cb9101
math1102e
chme0017
fc307
mkt60104
5522usst
litr1-uc6201.200
ee1102
cosc2803
math39512
omp9727
int2067/int5051
bsb151
mgt253
fc021
babs2202
mis2002s
phya21
18-213
cege0012
mdia1002
math38032
mech5125
07
cisc102
mgx3110
cs240
11175
fin3020s
eco3420
ictten622
comp9727
cpt111
de114102d
mgm320h5s
bafi1019
math21112
efim20036
mn-3503
fins5568
110.807
bcpm000028
info6030
bma0092
bcpm0054
math20212
ce335
cs365
cenv6141
ftec5580
math2010
ec3450
comm1170
ecmt1010
csci-ua.0480-003
econ12-200
ib3960
ectb60h3f
cs247—assignment
tk3163
ics3u
ib3j80
comp20008
comp9334
eppd1063
acct2343
cct109
isys1055/3412
math350-real
math2014
eec180
stat141b
econ2101
msinm014/msing014/msing014b
fit2004
comp643
bu1002
cm2030
联系我们
- QQ: 99515681 微信:codinghelp
© 2024
www.7daixie.com
站长地图
程序辅导网!