CS253编程代做、代写C/C++语言程序、c++编程设计调试帮做Java程序|代写Web开发

CS253 HW6: More classes!
Changes
Updates to the assignment will be noted here. None yet!
Description
For this assignment, you will take your work from HW4, and create two
classes, Board and Rule. You will provide Board.h, Rule.h, and the library
libhw6.a.
The Board class holds the grid of cells. The Rule class is concerned with the
rule for birth/survival, and is used by the Board class to determine the
contents of the next generation.
Methods
Rule must have the following public methods:
Default ctor
Constructs.
Destructor
Destroys.
.conway()
Use Conway’s rule, as used in HW2. If no methods are called on a Rule object, act as if .conway()
had been called.
.golly(string)
Use the given rule, in Golly notation. For example, .golly("B234/S018"). If the argument is
invalid, as described in HW4, throw a runtime_error, which must contain the entire argument.
.golly()
Return the Golly string currently in effect. If .conway() is in effect, return a Golly string that
describes Conway’s rule.
.eval(nw,n,ne,w,me,e,sw,s,se)
Evaluate the current rule for the given arguments, return true if a cell should be here next time (via
birth or survival), and false if no cell should be here next time. The nine bool arguments
represent the immediate neighborhood of the cell in question, including the cell itself (true for
alive, false for dead):
nw n ne
w me e
sw s se
Board must have the following public methods:
Board(string lename,
Rule rule, char live, char dead)
Board(string lename,
char live, char dead, Rule rule)
Board(string lename,
char live, char dead)
Board(string lename,
Rule rule)
Board(string lename)
Read a board from lename,
using live and dead as the alive & dead chars for both input & output,
and associate rule with it. Any problems with reading (bad lename,
bad contents, lines of different
lengths, etc.) result in throwing a runtime_error, including the lename,
that describes the
problem.
2020/11/13 CS253 | Main / HW6
https://cs.colostate.edu/~cs253/Fall20/HW6 2/5
p
If rule isn’t given, use a default-constructed Rule. Changing a rule after it’s been given to a Board
has no effect on that Board. This is true even if the given Rule falls out of scope and is destroyed.
If the live and dead arguments are not given, assume 'O' for a live cell and '.' for a dead one.
Destructor
Destroys.
Preincrement
Replace the current contents with the next generation, according to the associated Rule. Returns
the board after incrementing.
Non-methods:
ostream << Board
Write the current board, using its live and dead chars.
Const-correctness, for arguments, operands, methods, and operators, is your job. For example, it must be
possible to call .golly() with no arguments on a const Rule, or display a const Board.
You may dene
other methods or data, public or private, as you see t.
You may dene
other classes, as
you see t.
However, to use the Board class, the user need only #include "Board.h". To use the Rule
class, the user need only #include "Rule.h". We may test them separately.
Input/output format
Use the same input format as HW4, taking any given live and dead chars into account.
Each row ends with a newline, including the last one. Therefore, reading or writing a 2×2 board
transmits exactly 6 bytes.
Errors
Attempting to read a Board with fewer than two rows or columns must result in throwing a
runtime_error that mentions the lename.
All errors are indicated by throwing a runtime_error with an explanatory message. The exact string
thrown is up to you, but should be descriptive and understandable by the TA.
No method should call exit(), or produce any output.
Hints
Nobody said that you have to write the default ctor & dtor. If the default methods work for you, great!
Use default arguments and constructor forwarding. Remember that Java is different.
The foolish student will put main() in Board.cc, and try to remember to remove it before turning in
the homework. Good luck with that. Just put it in a separate le.
Libraries
libhw6.a is a library
le.
It contains a number of *.o (object) les.
It must contain Board.o & Rule.o, but it may also contain
whatever other *.o les
you need. The CMakeLists.txt shown creates libhw6.a. It does not contain
main().
Testing
You will have to write a main() function to test your code. Put it in a separate le,
and do not make it part
f libh 6 W ill t t b d i thi lik thi
2020/11/13 CS253 | Main / HW6
https://cs.colostate.edu/~cs253/Fall20/HW6 3/5
of libhw6.a. We will test your program by doing something like this:
mkdir a-new-directory
cd the-new-directory
tar -x < /some/where/else/hw6.tar
cmake . && make
cp /some/other/place/test-program.cc .
g++ -Wall test-program.cc libhw6.a
./a.out
We will supply a main program to do the testing that we want. You should do something similar.
Sample Run
Here is a sample run, where % is my shell prompt:
% cmake .
… cmake output appears here …
% make
… make output appears here …
% cat CS253
``@@@```@@@`@@@``@@@@``@@@```
`@```@`@```````@`@````@```@``
`@``````@@```@@``@@@`````@```
`@```@````@`@```````@`@```@``
``@@@``@@@``@@@@`@@@```@@@```
% cat blinker
....
.O..
.O..
.O..
....
% cat test.cc
#include "Board.h"
#include "Rule.h"
#include "Board.h"
#include "Rule.h"
#include
#include
using namespace std;
int main() {
Rule r;
assert(r.golly() == "B3/S23");
r.golly("B1357/S2468");
assert(r.golly() == "B1357/S2468");
Board g1("CS253", r, '@', '`');
cout << g1 << '\n';
cout << ++g1 << '\n';
cout << ++g1 << "\n\n";
r.conway();
assert(r.golly() == "B3/S23");
Board g2("blinker", r);
cout << g2 << '\n';
cout << ++g2 << '\n';
2020/11/13 CS253 | Main / HW6
https://cs.colostate.edu/~cs253/Fall20/HW6 4/5
cout << ++g2 << \n ;
cout << ++g2 << "\n\n";
Board g3("/s/bach/a/class/cs253/pub/Life/r");
for (int i=0; i<500; i++)
++g3;
cout << g3;
}
% ./test
Requirements
You may not use any external programs via system(), fork(), popen(), execl(), execv(), …
You may not use C-style I/O facilities such as printf(), scanf(), fopen(), getchar(), getc(),
etc.
Instead, use C++ facilities such as cout, cerr, and ifstream.
You may not use dynamic memory via new, delete, malloc(), calloc(), realloc(), free(),
strdup(), etc.
It’s ok to implicitly use dynamic memory via containers such as string or vector.
No global variables.
For readability, don’t use ASCII int constants (65) instead of char constants ('A') for printable
characters.
We will compile your code like this: cmake . && make
If that generates warnings, you will lose a point.
If that generates errors, you will lose all points.
There is no automated testing/pre-grading/re-grading.
Test your code yourself. It’s your job.
Even if you only change it a little bit.
Even if all you do is add a comment.
If you have any questions about the requirements, ask. In the real world, your programming tasks will
almost always be vague and incompletely specied.
Same here.
Tar le
The tar le
for this assignment must be called: hw6.tar
It must contain:
source les
(*.cc), including Board.cc & Rule.cc
header les
(*.h), including Board.h & Rule.h
CMakeLists.txt, which will create the library le
libhw6.a.
These commands must produce the library libhw6.a:
cmake . && make
Your CMakeLists.txt must use at least -Wall when compiling.
How to submit your work:
In Canvas, check in the le
hw6.tar to the assignment “HW6”.
How to receive negative points:
Turn in someone else’s work.

热门主题

课程名

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
联系我们
EMail: 99515681@qq.com
QQ: 99515681
留学生作业帮-留学生的知心伴侣!
工作时间:08:00-21:00
python代写
微信客服:codinghelp
站长地图