Question: This is the code started by our teacher: Peg Header File: https://codeshare.io/GAp7Zl Towers Header File: https://codeshare.io/2EkVZO Main File: https://codeshare.io/5MkyWO I need Implementation Files for the

This is the code started by our teacher:
Peg Header File: https://codeshare.io/GAp7Zl
Towers Header File: https://codeshare.io/2EkVZO
Main File: https://codeshare.io/5MkyWO
I need Implementation Files for the two class Header Files and the completed Header Files.
This is some more starter code from our teacher:
PegWithRings.h: https://codeshare.io/2pAY0D
PegWithRings.cpp: https://codeshare.io/5ONZdN
Source.cpp: https://codeshare.io/5Q87nm
This is the code from our book that we are supposed to be taking from:
Header File: https://codeshare.io/5w93nP
Implementation File: https://codeshare.io/29brO1
Main File: https://codeshare.io/5ez4VJ
12 keeps track of rings stacked on a peg, rather like phonograph records on a spindle. An example with five rings is shown here Rings stacked on a peg The peg may hold up to 64 rings, with each ring having its own diameter. Also, there is a rule that re quires each ring to be smaller than any ring under neath it, as shown in our example. The class's member functions should include: (a) a constructor that places n rings on the peg (where n may be as arge as 64); use 64 for a default argument. These n rings have diameters from n inches (on the bottom) to l-inch (on the top). (b) a constant member func tion that returns the number of rings on the peg. (c) a constant member function that returns the diameter of the topmost ring. (d) a member function that adds new ring to the top (with the diameter of the ring a parameter to the function). (e) a member func tion that removes the topmost ring. (f an overload ed output function that prints some clever representation of the peg and its rings. Make sure that all functions have appropriate preconditions to guarantee that the rule about ring sizes is enforced. Also spend time designing appropriate private data fields. 13 ment a class called towers, which is part of a program that lets a child play a game called Towers of Hanoi. The game consists of three pegs and a collection of rings that stack on the pegs The rings are different sizes. The initial configura tion for a five-ring game is shown here, with the first r having rings ranging in size from one inch (on the top) to five inches (on the bottom) Initial configuration for a five-ring game of Towers of Hanoi The rings are stacked in decreasing order of their size, and the second and third towers are initially empty. During the game, the child may transfer rings one at a time from the top of one peg to the top of another. The object of the game is to move all the rings from the first peg to the second peg. The diffi culty is that the child may not place a ring on top of one with a smaller diameter. There is the one extra peg to hold rings temporarily, but the prohibition against a larger ring on a smaller ring applies to it as well as to the other two pegs. A solution for a three ring game is shown here At game start After 1 move After 2 moves After 3 moves After 4 moves After 5 moves After 6 moves After 7 moves The towers class must keep track of the status of all three pegs. You might use an array of three pegs where each peg is an object from the previous project. The towers functions are specified her towers towers (size t n 64) Precondition 1 n 64 Postcondition: The towers have been initialized with n rings on the first peg and no rings on the other two pegs. The diameters of the first eg's rings are from one inch (on the top) to n inches (on the bottom) size t towers many-rings Cint peg number) const; Precondition: peg-number is 1, 2, or 3 Postcondition: The return value is the number of rings on the specified peg size t towers top diameter (int peg number) const Precondition: peg-number is 1, 2, or 3 if then the return value is the diameteroft ring on the specified peg, otherwise the ret value is zero void towers move nt start peg; int end peg); Precondition: start peg is a peg number (1, 2, or 3), and many.rings start peg) end peg is a different peg number (not equal to start peg), and top diameterlend.peg) is either o or more than top diameter(start.pea Postcondition: The top ring has been moved from start-peg to end peg. Also overload the output operator so that a towers object may be displayed easily. Use the towers object in a program that allo child to play Towers of Hanoi. Make sure that you don't allow the child to make any illegal moves 12 keeps track of rings stacked on a peg, rather like phonograph records on a spindle. An example with five rings is shown here Rings stacked on a peg The peg may hold up to 64 rings, with each ring having its own diameter. Also, there is a rule that re quires each ring to be smaller than any ring under neath it, as shown in our example. The class's member functions should include: (a) a constructor that places n rings on the peg (where n may be as arge as 64); use 64 for a default argument. These n rings have diameters from n inches (on the bottom) to l-inch (on the top). (b) a constant member func tion that returns the number of rings on the peg. (c) a constant member function that returns the diameter of the topmost ring. (d) a member function that adds new ring to the top (with the diameter of the ring a parameter to the function). (e) a member func tion that removes the topmost ring. (f an overload ed output function that prints some clever representation of the peg and its rings. Make sure that all functions have appropriate preconditions to guarantee that the rule about ring sizes is enforced. Also spend time designing appropriate private data fields. 13 ment a class called towers, which is part of a program that lets a child play a game called Towers of Hanoi. The game consists of three pegs and a collection of rings that stack on the pegs The rings are different sizes. The initial configura tion for a five-ring game is shown here, with the first r having rings ranging in size from one inch (on the top) to five inches (on the bottom) Initial configuration for a five-ring game of Towers of Hanoi The rings are stacked in decreasing order of their size, and the second and third towers are initially empty. During the game, the child may transfer rings one at a time from the top of one peg to the top of another. The object of the game is to move all the rings from the first peg to the second peg. The diffi culty is that the child may not place a ring on top of one with a smaller diameter. There is the one extra peg to hold rings temporarily, but the prohibition against a larger ring on a smaller ring applies to it as well as to the other two pegs. A solution for a three ring game is shown here At game start After 1 move After 2 moves After 3 moves After 4 moves After 5 moves After 6 moves After 7 moves The towers class must keep track of the status of all three pegs. You might use an array of three pegs where each peg is an object from the previous project. The towers functions are specified her towers towers (size t n 64) Precondition 1 n 64 Postcondition: The towers have been initialized with n rings on the first peg and no rings on the other two pegs. The diameters of the first eg's rings are from one inch (on the top) to n inches (on the bottom) size t towers many-rings Cint peg number) const; Precondition: peg-number is 1, 2, or 3 Postcondition: The return value is the number of rings on the specified peg size t towers top diameter (int peg number) const Precondition: peg-number is 1, 2, or 3 if then the return value is the diameteroft ring on the specified peg, otherwise the ret value is zero void towers move nt start peg; int end peg); Precondition: start peg is a peg number (1, 2, or 3), and many.rings start peg) end peg is a different peg number (not equal to start peg), and top diameterlend.peg) is either o or more than top diameter(start.pea Postcondition: The top ring has been moved from start-peg to end peg. Also overload the output operator so that a towers object may be displayed easily. Use the towers object in a program that allo child to play Towers of Hanoi. Make sure that you don't allow the child to make any illegal moves
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
