Convert your c version of the hoarding game into cpp version

Assignment Help C/C++ Programming
Reference no: EM131858756

Assignment

Description

Convert your C version of the hoarding game into a C++ version

Changes

Input and output are for the C and C++ versions are the same EXCEPT for the following

? Users will enter their names at the beginning of the program. These will be displayed instead of 0, 1, 2, 3, ...

? Displaying the gamestate has been changed and follows this pattern

- Space Number | Space Name | Owner | Players

- If no one owns the property the Owner is None
- Players are displayed as [player_name : $cash_held]
- When multiple players are on the same space they are displayed based on the order they were created in

? Users can only roll dice and leave the game now as the player details are now constantly visible

Requirements

1. Your code must have at LEAST the following classes. You may have more but you must have at least these

? Gamestate
? Board
? Player
? Space
? Property
? DiceRoller
? Rules

2. All of your classes and free standing functions must be inside of a namespace named Monopoly. For some reason CLion has issues autocompleting the members when inside the namespace but the members are still there. You just have to type them out manually.

3. Any dynamic space you allocate must be managed by a smart pointer.

Restrictions

You may not use the following in your code

? Structs
? Global variables

- Class static variables are ok

? Regular enums

- You can still use class enums

? Arrays either dynamically or statically allocated except for argv

? C strings except for those located in argv

- String literals strings in your code that appear inside "" are still ok

? Any C functions except for printf, scanf, fopen, fclose, fscanf, and sscanf

- If you are looking for an equivalent to atoi see stoi

? using namespace std;

? new or delete

- Your dynamic memory allocation is being managed by smart pointers so there is no need to call these function

Hints and Advice

Think about your design before coding

A little bit of thought about how you want to structure your solution goes a long way in producing neat, understandable code. Think about how you want to structure your classes.

What is each made up of? What do you want each to be able to do?

That being said you'll encounter problems that you didn't consider when you start coding so your design will need to change to handle them. That's ok and a natural part of programming just update your design accordingly but don't forget the big picture when doing so.

Break your problems down

Break your problems down. Break your problems down. Break your problems down. You really want to be doing this as it makes solving this problem and any others much much easier. Start with our big steps. For each one of those big steps, break it into slightly smaller but still big steps.Each of these steps will eventually become a function call. Keep doing this until you finally get down to a step that can be solved in a few lines of code (around 1 - 20 lines) and then put your solution there.

Each of your functions should probably be nore more than 25 lines of code. There might be some exceptions but if you are going over 25 then you really should start breaking down the parts of your problem into more functions. Trust me when I say this as I say it from a place of experience, that it is much easier to read, understand, maintain, and update small functions then it is with large functions. This is true even if you create hundreds of small functions as each of those functions on their own will be really easy to understand because they are small. If you've been writing really long functions use this project as place to break those bad habits and start reaping the benefits of small functions.

Avoid Circular Inclusions

It's very likely that your code will have circular references in it. For example a player owns Properties but your Property could have a Player* to reference who their owner is. This is completely fine, normal, and a good design. What you need to be careful with in our design is not to have circular inclusions, either direct or indirect. A circular inclusion is when a .h file, say A.h, includes another file, say B.h, that includes A.h. This could either be direct, B.h has a #include "A.h" in it or it includes another file that includes A.h. For example B.h could include C.h which includes D.h which includes A.h.

Code with circular includes like this will not compile correctly. To get this to work you should define a strict order of when you will include files in your header and when you will use a forward declaration of the class. For me I said that if two classes were mutually dependent on each other then if one class is made of the other it would include that class. If the other class only referenced the first class it would have only a forward reference. For example a Player has Properties but a Property only refers to a player, so Player would include Property and Property would have a forward reference to Player. Then since I needed to use Player methods in Property.cpp I would include Player.h in Property.cpp to get access to them.

What rule you pick to break circular inclusions doesn't really matter, the important part is that you are consistent following.

And as a reminder forward declarations of classes only needed when circular referencing starts happening in your code.

Consider using a vector of Player* instead of just Player

When storing your players it might be easier to have a vector <unique_ptr<Player> > instead of just a vector<Player> as under this setup you know that your players won't move locations in memory if you have to remove elements from your array and you get to control precisely when the elements are deleted. To add a unique pointer to a vector don't forget to use std::move. For example if I have a unique pointer up and and want to add it to the end of a vector, v, I would do v.push_back(std::move(up)).

Attachment:- Original-C-File.rar

Reference no: EM131858756

Questions Cloud

Provide the treatment and services that drug offenders need : Can the criminal justice system ever hope to provide the treatment and services that drug offenders need?
Identify the strengths and weaknesses of drug : Briefly describe the extent of the offender population that is involved with drug use.
How many units should be produced in each month : There currently is 1 unit in inventory, and we want to have 2 units in inventory at the end of 3 months. A maximum of 3 units can be produced on regular-time.
What is the traditional action research model : What is the Traditional Action Research Model? Explain each step.
Convert your c version of the hoarding game into cpp version : Convert your C version of the hoarding game into a C++ version. Users will enter their names at the beginning of the program.
Some states impose a fine or imprisonment : Some states impose a fine or imprisonment on anyone over the age of 18 who neglects or refuses to support a parent
Discuss the different types of sampling techniques : Discuss the different types of sampling techniques that are used in field research.
How does select an appropriate forecasting method : What should be considered in selecting an appropriate forecasting method? What do you think about combining statistical forecasts and judgment?
Evaluate the effectiveness of the leader : Evaluate the effectiveness of the leader within your example using either expectancy or equity theory.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Calculate the total for each student

Calculate the total for each student - calculate the average for each of the assessments

  Generate a set of 75 random integers in the range -26 to + 4

Write a program that will generate a set of 75 random integers in the range -26 to + 42. The program

  Write a program that will read in number of 2 point basket

Write a program that will read in the number of 2 point baskets and the number of 3 point baskets a player makes.  Print the number of each baskets and the total number of points scored.

  Development team modify

The application used to calculate the cost of carrying additional luggage results in erroneous amount, if the weight of the luggage is a fractional number. Help the development team modify the code snippet so that the cost of carrying additional l..

  How object-oriented analysis and design differs

Explain how object-oriented analysis and design differs from the traditional approach. Why isn't RUP (Figure) represented as a cycle? is that good or bad?

  Write a program that creates an arraylist

Write a program that creates an ArrayList and adds a Loan Object, a Date Object, a string, JFrame object, and a circle object to the list, and use a loop to display all the elements in the list by invoking the object's toString() method.

  Write program to simulate rolling of two dice hundred times

Design, implement, test, and debug a C# program to simulate the rolling of two dice 100 times. Whenever the two dice display the same number, the program should show the roll sequence number.

  Create an array of objects from the provided code

Create an array of objects from the provided code and run a for loop to assign strings and numbers. In this assignment, I will need to see the main function. Make sure there is a default constructor.

  Rewrite the overloaded input operator for the ratio class

Rewrite the overloaded input operator for the Ratio class so that, instead of prompting for the numerator and denominator, it reads a fraction type as "22/7".

  Definitions for object-oriented programming

Compare the definitions and compile them into one definition in your own words. Justify your answers using examples and reasoning.

  Program that reads a student''s name together with score

A value-returning function, calculateGrade, to determine and return each student's grade. (This function does not output the grade. That task must be done in the function main.)

  Write a program to test the functions by computing function

Write a program to test the functions by computing F = 5 tanh(ax) + 4 cos(ax) where 0 ≤ x

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd