CS253编程 写作、 辅导C/C++语言程序

” CS253编程 写作、 辅导C/C++语言程序CS253 HW6: More classes!ChangesUpdates to the assignment will be noted here. None yet!DescriptionFor this assignment, you will take your work from HW4, and create twoclasses, Board and Rule. You will provide Board.h, Rule.h, and the librarylibhw6.a.The Board class holds the grid of cells. The Rule class is concerned with therule for birth/survival, and is used by the Board class to determine thecontents of the next generation.MethodsRule must have the following public methods:Default ctorConstructs.DestructorDestroys..conway()Use Conways 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 isinvalid, 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 thatdescribes Conways 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 (viabirth or survival), and false if no cell should be here next time. The nine bool argumentsrepresent theImmediate neighborhood of the cell in question, including the cell itself (true foralive, false for dead):nw n new me esw s seBoard 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 differentlengths, etc.) result in throwing a runtime_error, including the lename,that describes theproblem.2020/11/13 CS253 | Main / HW6 httpss://cs.colostate.edu/~cs253/Fall20/HW6 2/5pIf rule isnt given, use a default-constructed Rule. Changing a rule after its been given to a Boardhas 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.DestructorDestroys.PreincrementReplace the current contents with the next generation, according to the associated Rule. Returnsthe board after incrementing.Non-methods:ostream BoardWrite the current board, using its live and dead chars.Const-correctness, for arguments, operands, methods, and operators, is your job. For example, it must bepossible to call .golly() with no arguments on a const Rule, or display a const Board.You may deneother methods or data, public or private, as you see t.You may Deneother classes, asyou see t.However, to use the Board class, the user need only #include Board.h. To use the Ruleclass, the user need only #include Rule.h. We may test them separately.Input/output formatUse 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 22 boardtransmits exactly 6 bytes.ErrorsAttempting to read a Board with fewer than two rows or columns must result in throwing aruntime_error that mentions the lename.All errors are indicated by throwing a runtime_error with an explanatory message. The exact stringthrown is up to you, but should be descriptive and understandable by the TA.No method should call exit(), or produce any output.HintsNobody 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 inthe homework. Good luck with that. Just put it in a separate le.Librarieslibhw6.a is a libraryle.It contains a number of *.o (object) les.It must contain Board.o Rule.o, but it may also containwhatever other *.o lesyou need. The CMakeLists.txt shown creates libhw6.a. It does not containmain().TestingYou will have to write a main() function to test your code. Put it in a separate le,and do not make it partf libh 6 W ill t t b d i thi lik thi2020/11/13 CS253 | Main / HW6 httpss://cs.colostate.edu/~cs253/Fall20/HW6 3/5of libhw6.a. We will test your program by doing something like this:mkdir a-new-directorycd the-new-directorytar -x /some/where/else/hw6.tarcmake . makecp /Some/other/place/test-program.cc .g++ -Wall test-program.cc libhw6.a./a.outWe will supply a main program to do the testing that we want. You should do something similar.Sample RunHere 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 iostream#include cassertusing 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 httpss://cs.colostate.edu/~cs253/Fall20/HW6 4/5cout ++g2 \n ;cout ++g2 \n\n;Board g3(/s/bach/a/class/cs253/pub/Life/r);for (int i=0; i500; i++)++g3;cout g3;}% ./testRequirementsYou 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.Its ok to implicitly use dynamic memory via containers such as string or vector.No global variables.For readability, dont use ASCII int constants (65) instead of char constants (A) for printablecharacters.We will compile your code like this: cmake . makeIf 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. Its 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 willAlmost always be vague and incompletely specied.Same here.Tar leThe tar lefor this assignment must be called: hw6.tarIt must contain:source les(*.cc), including Board.cc Rule.ccheader les(*.h), including Board.h Rule.hCMakeLists.txt, which will create the library lelibhw6.a.These commands must produce the library libhw6.a:Cmake . makeYour CMakeLists.txt must use at least -Wall when compiling.How to submit your work:In Canvas, check in the lehw6.tar to the assignment HW6.How to receive negative points:Turn in someone elses work.如有需要,请加QQ:99515681 或邮箱:99515681@qq.com

添加老师微信回复‘’官网 辅导‘’获取专业老师帮助,或点击联系老师1对1在线指导