Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can some help me write those functions in C++. I am getting errors in my functions and since I can not share them here I

Can some help me write those functions in C++. I am getting errors in my functions and since I can not share them here I would like to see how someone else would build them. I really just need to see the functions_cpp

Proj description

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

file1.pf file2.pf file3.pf file4.pf file5.pf

SetDim 15 23 SetPenPosition 5 5 SetDim 15 15 gobbledy-gook # gobbledy-gook a comment

SetPenPosition 12 12

proj.h

#pragma once

#include #include #include

// the type that you must provide class Painter {

public: // You must porovide these functions with exactly this signature // Painter Constructor Painter(const std::string &fname); // this function parses the file, draws the canvas, and logs errors void CreateCanvas();

//std::vector<:string> GetCanvas() const { //return the canvas //return canvas_;}

std::vector<:string> GetErrorLog() const { // return the error log return error_log_;}

private: // the private stuff that we won't be testing directly // All of these are optional, but are guides to how you can build the class

// directions (can be represented by ints, but an enum class is cleaner) enum class direction { up, down, left, right }; // store the direction direction dir_ = direction::right;

// number of rows in the canvas int rows_ {10};

// number of columns in the canvas int columns_{10};

// the current pen_symbol char pen_symbol_{'#'};

// pen position can be represented by a pair or 2 different ints, etc // std::pair pen_position_{0,0};

// the actual canvas std::vector<:string> canvas_ = std::vector<:string>(rows_,std::string(columns_,' '));

// the error log std::vector<:string> error_log_;

// the lines of the .pf file (with line numbers). A vector of strings, where // the position represents the line number is also reasonable // std::map lines_;

// These are functions that you will probably find useful to write // Note that these functions are up to you; change the names, signature, etc. // add functions if you want, of course // Whatever works for you

// Parse a single line. (A good place to record a line error to the log // void Parse(int line_num,const std::string& line);

// reset the dimensions of the canvas void SetDim(int line_num, int x_dim, int y_dim);

// Set the position of the pen // void SetPenPosition(int line_num, int x_pos, int y_pos);

// Set the pen symbol // void SetPenSymbol(int line_num, int pen_symbol);

// Draw the current symbol at the current position // void Draw();

// Move the pen in the direction it is facing n steps // void Move(int n);

// Turn the pen 90 degrees clockwise n times // void Turn(int n);

// Repeat a range of commands the specified number of times // void Repeat(int line_num,int n, int start, int end); };

Background KTurtle (https://en.wikipedia.org/wiki/KTurtle) is a cool graphics-drawing application that has its own mini-programming-language. For this project, we will be writing a program (in C++), that parses a script written in a version of this mini-language and draws characters on a canvas. To make this simple, we will be drawing ASCII characters on regular output (std::cout). You might call this ASCII art. The programming language is pretty simple, e.g, we won't have colours, different sized cursors, etc. In particular, our mini-scripting-language won't be braced, so you don't have to recognize nested structures. Still, our mini-language will be able to generate some interesting graphics. A script consists of a set lines where each line is a command. The lines are implicitly numbered (the numbers are not part of the script) starting with Line number 1 1. SetDim 10 12 2. Repeat 100 3-7 3. Draw 4. Move 1 5. Turn 1 6. Move 1 7. Turn 3 generates the following: Background KTurtle (https://en.wikipedia.org/wiki/KTurtle) is a cool graphics-drawing application that has its own mini-programming-language. For this project, we will be writing a program (in C++), that parses a script written in a version of this mini-language and draws characters on a canvas. To make this simple, we will be drawing ASCII characters on regular output (std::cout). You might call this ASCII art. The programming language is pretty simple, e.g, we won't have colours, different sized cursors, etc. In particular, our mini-scripting-language won't be braced, so you don't have to recognize nested structures. Still, our mini-language will be able to generate some interesting graphics. A script consists of a set lines where each line is a command. The lines are implicitly numbered (the numbers are not part of the script) starting with Line number 1 1. SetDim 10 12 2. Repeat 100 3-7 3. Draw 4. Move 1 5. Turn 1 6. Move 1 7. Turn 3 generates the following

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Instant Reference

Authors: Gruber, Martin Gruber

2nd Edition

ISBN: 0782125395, 9780782125399

More Books

Students also viewed these Databases questions

Question

How do Data Types perform data validation?

Answered: 1 week ago

Question

How does Referential Integrity work?

Answered: 1 week ago