(C++) Racetrack input: /*CXX_FLAGS -Wall -Wpedantic -Werror*/ 2 3 #include “course.h” 4 #include…

(C++) Racetrack

input:

/*CXX_FLAGS -Wall -Wpedantic -Werror*/
2
3 #include “course.h”
4 #include
5 #include
6 #include
7
8 std::string const map_layout_1 = R”(
9 .*****
10 .*..F.
11 .S….
12 )”;
13
14 Course c1(map_layout_1);
15
16 Vehicle v1(‘A’);
17 Vehicle v2(‘B’);
18 c1.AddVehicleToStart(&v1);
19 c1.AddVehicleToStart(&v2);
20 v1.SetBearing(‘W’);
21 v2.SetBearing(‘N’);
22 v1.MoveForward();
23 v2.MoveForward();
24
25 std::ostringstream oss;
26
27 std::cout << “Before Return” << std::endl;
28 std::cout << c1;
29
30 oss << “Before Return” << std::endl;
31 oss << c1;
32
33
34 ASSERT_EQ(oss.str(), “Before Returnn++++++++n+.*****+n+.B..F.+n+AS….+n++++++++n”);
35 oss.str(“”);
36
37 int num_returned = c1.ReturnOffTrackVehiclesToStart();
38
39 ASSERT_EQ(num_returned, 1);
40
41 std::cout << “After First Return” << std::endl;
42 std::cout << c1;
43
44 oss << “After First Return” << std::endl;
45 oss << c1;
46
47 ASSERT_EQ(oss.str(), “After First Returnn++++++++n+.*****+n+.B..F.+n+.A….+n++++++++n”);
48 oss.str(“”);
49
50 v2.SetBearing(‘S’);
51 v1.MoveForward();
52 v2.MoveForward(-1);
53 v2.TurnRight();
54 v2.MoveForward();
55
56 std::cout << “After Second Move” << std::endl;
57 std::cout << c1;
58
59 oss << “After Second Move” << std::endl;
60 oss << c1;
61
62 ASSERT_EQ(oss.str(), “After Second Moven++++++++n+B*****+n+.*..F.+n+AS….+n++++++++n”);
63 oss.str(“”);
64
65 num_returned = c1.ReturnOffTrackVehiclesToStart();
66
67 ASSERT_EQ(num_returned, 2);
68
69 std::cout << “After Second Return” << std::endl;
70 std::cout << c1;
71
72 oss << “After Second Return” << std::endl;
73 oss << c1;
74
75 ASSERT_EQ(oss.str(), “After Second Returnn++++++++n+.*****+n+.*..F.+n+.B….+n++++++++n”);
76 oss.str(“”);
77
78 v1.TurnRight();
79 v1.MoveForward();
80 v2.MoveForward();
81
82 std::cout << “After Third Move” << std::endl;
83 std::cout << c1;
84
85 oss << “After Third Move” << std::endl;
86 oss << c1;
87
88 ASSERT_EQ(oss.str(), “After Third Moven++++++++n+.*****+n+.A..F.+n+BS….+n++++++++n”);
89 oss.str(“”);
90
91

output:

++++++++

+.*****+

+.B..F.+

+AS….+

++++++++

After First Return

++++++++

+.*****+

+.B..F.+

+.A….+

++++++++

After Second Move

++++++++

+B*****+

+.*..F.+

+AS….+

++++++++

After Second Return

++++++++

+.*****+

+.*..F.+

+.B….+

++++++++

After Third Move

++++++++

+.*****+

+.A..F.+

+BS….+

++++++++

Description:(look for input and output above)

For this project, you will be writing two classes: Course and Vehicle. Each class will need to implement the following public member functions. All other member attributes and member functions must be private. Important note, this project makes use of raw (non-smart) pointers, best practices would be to not do so, but we need to test your comprehension of pointers even if they aren’t the best possible way to acheive the desired functionality.

Class Course:

The class named Course should be implemented in the files named “course.cpp” and “course.h”. It should have a constructor that takes a multiline string that denotes a 2-d racetrack. The periods are the grass, the asterisks are pavement, the ‘S’ character denotes the start position, and the ‘F’ denotes the finish position. Please ignore empty lines and any non-newline whitespace. The Course class should be able to use the insertion operator to write the layout to an ostream. Pelase wrap the layout in ‘+’ (plus signs) to make it easier to distinguish multiple courses printed to the same stream.

A void member function named “AddVehicleToStart” should take a pointer to a Vehicle object. This member function is used to register a Vehicle with the Course. Henceforth, the insertion operator should show where that Vehicle is on the course (starting at the start (S)). If multiple Vehicles occupy the same position, display only the most recently provided to the “AddVehicleToStart”.

Course should implement a copy constructor that copies the layout, but not the Vehicles on it.

Course should implement an assignment operator that assigns the layout and the vehicles to the lhs. Be sure the rhs no longer has any vehicles post assignment.

To aid in course management, you need to add two additional member functions to the Course class. The member function named “VehiclesAtFinish” takes no parameters, and returns a std::set of Vehicles denoting the Vehicles that are currently occupying the Finish position. The second member function is “ReturnOffTrackVehiclesToStart” which also doesn’t take any parameters. Its primary purpose is to move all Vehicles that aren’t on the course (meanng not on S, *, or F positions) to the start. Be sure not to change the bearing of the Vehicle when moving it. This function should return the number of Vehicles that needed to be moved.

Class Vehicles:

The class named Vehicle should be implemented in the files named “vehicle.cpp” and “vehicle.h”. Vehicles are constructed with a char. This char is how the Vehicle is represented in the course layout. Vehicles need to implement the < and == operators, using their char for comparisons. When a Vehicle is written to an ostream, write its char. Vehicles have a SetBearing member function that takes a char (‘N’, ‘S, ‘E’, or ‘W’), which denotes the cardinal direction the object is facing, anything else should throw an std::invalid_argument exception. The MoveForward member function takes an int (defaulting to 1) indicating how many spaces to move in the direction of its bearing. For example, if a Vehicle’s bearing is East and it move forward by 2. its location is 2 spaces to the right (as depicted in the Course’s layout). Vehicles also have TurnLeft and TurnRight member functions that adjust its bearing. Of course, if you TurnLeft 4 times, you are back to your original bearing.

Each Vehicle will only be associated with at most one Course.

Manual Grading:

Please ensure you follow all the best practices and style guide recommendations that have been described throughout the course. Use const, references, access controls and algorithms as appropriate. Be sure your code is well styled, legible, and commented when appropriate

Place your order
(550 words)

Approximate price: $22

Calculate the price of your order

550 words
We'll send you the first draft for approval by September 11, 2018 at 10:52 AM
Total price:
$26
The price is based on these factors:
Academic level
Number of pages
Urgency
Basic features
  • Free title page and bibliography
  • Unlimited revisions
  • Plagiarism-free guarantee
  • Money-back guarantee
  • 24/7 support
On-demand options
  • Writer’s samples
  • Part-by-part delivery
  • Overnight delivery
  • Copies of used sources
  • Expert Proofreading
Paper format
  • 275 words per page
  • 12 pt Arial/Times New Roman
  • Double line spacing
  • Any citation style (APA, MLA, Chicago/Turabian, Harvard)

Our guarantees

Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.

Money-back guarantee

You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.

Read more

Zero-plagiarism guarantee

Each paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.

Read more

Free-revision policy

Thanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.

Read more

Privacy policy

Your email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.

Read more

Fair-cooperation guarantee

By sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.

Read more
error: Content is protected !!