Annulleret

homework

• Your codes should be written in C++.

• In testing phase of evaluation, black box method will be used. So, be careful about input/output specifications.

(do not print any unnecessary characters, white spaces etc.). Your code may be inspected as well.

• Your code should be compiled on inek machines with the compiler g++.

Homework ??" Version Control System

Assume that you are working as a software engineer in a famous software company. At that time, you participate in a large

scale software project including thousands of source code files and engineering reports with hundreds of engineers and

coders. Naturally, such a company with such projects needs a version control system in order to control the operations on

the files used by many people. Such a system uses a version manipulation style for creating and keeping new versions of a

file in each update of the file. This style depends on the design of the version control system.

In this homework, you are supposed to simulate a simple part of a version control system for a given style of

implementation. The data structure template for keeping the files will be given. The objective is to implement the data

structure and define the required operations for this structure.

Problem Definition

• The whole Implementation consists of “VersionTree??, “SourceFile??, “VersionHelper?? and “Main??

classes.

## Deliverables

Homework #3

General Rules:

• Your codes should be written in C++.

• In testing phase of evaluation, black box method will be used. So, be careful about input/output specifications.

(do not print any unnecessary characters, white spaces etc.). Your code may be inspected as well.

• Your code should be compiled on inek machines with the compiler g++.

Homework ??" Version Control System

Assume that you are working as a software engineer in a famous software company. At that time, you participate in a large

scale software project including thousands of source code files and engineering reports with hundreds of engineers and

coders. Naturally, such a company with such projects needs a version control system in order to control the operations on

the files used by many people. Such a system uses a version manipulation style for creating and keeping new versions of a

file in each update of the file. This style depends on the design of the version control system.

In this homework, you are supposed to simulate a simple part of a version control system for a given style of

implementation. The data structure template for keeping the files will be given. The objective is to implement the data

structure and define the required operations for this structure.

Problem Definition

• The whole Implementation consists of “VersionTree??, “SourceFile??, “VersionHelper?? and “Main??

classes.

• These classes are separated into different source and header files:

• “VersionTree?? and “SourceFile?? classes are declared in the header file “versioner.h?? while they are

defined in the source file “[url removed, login to view]?

• “VersionHelper?? class is declared in the header file “version_helper.h?? while it is defined in the

source file “[url removed, login to view]?

• “Main?? class is declared in the header file “main.h?? while it is defined in the source file “[url removed, login to view]?

• You will only and necessarily implement “[url removed, login to view]?, “version_helper.h?? and “[url removed, login to view]?.

Therefore, you will submit only these three files. You will not be able to make any modification to the other

files. (As you will not submit them, modifying them means nothing)

• The header file “versioner.h?? will be given to you. You should implement the classes - declared in this file ??"

in the source file “[url removed, login to view]?.

• “VersionHelper?? class that will be declared in “version_helper.h?? should be implemented in

“[url removed, login to view]? (Implementation and declaration should be totally separated).

• “Main?? class that will be declared in “main.h?? will be implemented in “[url removed, login to view]?. We will implement this

class. Therefore, you will not be dealing with this class and its related files. Moreover, example (simple)

“main.h?? and “[url removed, login to view]? files will be given to you in order to make your job easier.

• Lastly, an “[url removed, login to view]? file including a main function will be given to you. Again, you will not deal with

this file and it is given to you in order to make your job easier.

• versioner.h

#ifndef _VERSIONER_H

#define _VERSIONER_H

#include <string>

using namespace std;

class VersionTree {

VersionTree * children;

VersionTree * rightSibling;

string versionName;

string versionDate;

string changeCommands;

public:

VersionTree(string versionName, string versionDate, string changeCommands);

friend class SourceFile;

friend class VersionHelper;

friend class Main;

};

class SourceFile {

string filePath;

string creationDate;

string fileContent;

VersionTree rootNode;

public:

SourceFile(string filePath, string creationDate);

void operate();

friend class VersionHelper;

friend class Main;

};

#endif

“VersionTree?? and “SourceFile?? classes are the brain of our version control system.

Their implementation will be in “[url removed, login to view]?.

VersionTree class is designed for keeping the version tree. “children?? field points to a linked list

representing the children of that version. As the number of versions of a file is unknown ahead of

time, the maximum number of children for any parent node is not fixed. “rightSibling?? field points

the right sibling of that version. Each element of the mentioned linked-list is linked with this

pointer.

o In the constructor: There are three parameters. “versionName??, “versionDate?? and

“changeCommands?? parameters should be set to the related fields while “children?? and

“rightSibling?? fields should be set to NULL.

SourceFile class keeps the file that should be versioned. Its constructor takes two arguments: The

path and the creation date of the file.

o In the constructor:

“filePath?? and “creationDate?? fields should be initialized with these two parameters.

“fileContent?? field should be initialized with the content of the file in the related path (You

may assume a file having textual data such as .txt, .cpp etc.). In other words, you will store

the content of the file to this string field by using file operations. “fileContent?? (string)

field should not include any EOF or newline characters at its end position(Control this

carefully and store the correct one). The maximum number of characters in a file can be

assumed as 10000.

“rootNode?? field should be initialized with the constructor of “VesrionTree?? giving “root??

string (as “versionName?? parameter), creationDate (as “versionDate?? parameter), “#??

string (as “changeCommands?? parameter).

By using this constructor, a “SourceFile?? object having only a root node in its version tree

can be created.

o In the operator function:

You will implement the capabilities of the system. For an object of type “SourceFile??, this

function should read a command list from standard input. The first line will be the number

of commands while each of the other lines will be each command. This function will

execute the operations required for each command on the version tree having root node as

“rootNode?? field in its object. The format of all operations is as follows:

addVersion <parentVersionName> <versionName> <versionDate> <changeCommands>

deleteVersion -r <versionName>

deleteVersion <versionName>

printVersion <versionName>

printVersionTree bfs

printVersionTree dfs

printVersionNumber <versionName>

printVersionContent <versionName>

An example input:

10

addVersion root root1 10/10/2008 c15?;d8;d3;

addVersion root1 root2 11/10/2008 c10*;

addVersion root root3 12/10/2008 d1;

deleteVersion -r root2

deleteVersion root1

printVersion root3

printVersionTree bfs

printVersionTree dfs

printVersionNumber root3

printVersionContent root3

addVersion command: This command creates a new version with versionName,

versionDate and changeCommands and adds it to the end of the children linked list of the

version (in the version tree) given by its name (parentVersionName). Version name is a

unique attribute. There cannot be any two versions with the same name in a version tree.

addVersion <parentVersionName> <versionName> <versionDate> <changeCommands>

deleteVersion -r command: This command deletes the version (in the version tree) given

by its name (versionName) recursively (meaning that it is deleted with all of its sub-trees if

it has any child).

deleteVersion -r <versionName>

deleteVersion command: This command deletes the version (in the version tree) given by

its name (versionName) non-recursively (meaning that only that version is deleted. Its

children are added to the place of its deleted parent. The children will now be between the

right and left siblings of its parent. The “changeCommand?? field of the deleted parent is

also added to the front of the “changeCommand?? field of all of its children by using string

concatenation).

deleteVersion <versionName>

printVersion command: This command prints the information of a version (in the version

tree) given by its name (versionName). “versionName??, “versionDate?? and

“changeCommands?? fields of the version are printed respectively by printing a blank

between them. A newline should also be printed at the end. Thus, a line with the related

information is printed.

printVersion <versionName>

printVersionTree bfs command: This command prints the whole version tree in a breadthfirst-

search (level-order) manner. Each line of the result is a printing (printing style is the

same with the style of printVersion command) of each version (in the tree) in breadth-firstsearch

order.

printVersionTree bfs

printVersionTree dfs command: This command prints the whole version tree in a depthfirst-

search manner. Each line of the result is a printing (printing style is the same with the

style of printVersion command) of each version (in the tree) in depth-first-search order.

printVersionTree dfs

printVersionNumber command: This command prints the version-number of a version (in the

version tree) given by its name (versionName). Version number of a version is found by

traversing the tree. Version number of the root is “1?? in default. The version number of the

second child of the root is “1.2??. The version number of the third child of the second child of

the root is “1.2.3??. A newline should also be printed at the end.

printVersionNumber <versionName>

Hint: Use depth-first search by using stack. You can use STL of C++ for stack.

Warning: Do not try to store the version numbers of all versions in somewhere else

during the creation time of the versions in order to avoid traversal. The version numbers

are dynamic. After a non-recursive delete operation lots of versions change their version

numbers.

printVersionContent command: This command prints the content of a version (in the version

tree) given by its name (versionName). Content is found by applying all “changeCommands??

of the versions residing in the path starting from the root to the mentioned version. (The

content of the root is the “fileContent?? field of the “SourceFile?? class)

printVersionContent <versionName>

Hint: Use depth-first search by using stack. You can use STL of C++ for stack.

Warning:Do not try to store the contents of all versions in somewhere else during the

creation time of the versions in order to avoid traversal. (Only the content of the root is

kept in the?? fileContent?? field of the “SourceFile?? object. All the other version contents

are relative to its parent represented by the “changeCommands?? field.) The tree may

have thousands of nodes. When you think that a file may be composed of 10000

characters. The total amount of memory to hold this data will be enormous when you

consider the context of this homework. The memory will be restricted in the evaluation

phase.

The “changeCommands?? field of each version holds the sequence of operations that

make the content of its parent different from its content. Example:

• Assume that the “fileContent?? field of “root?? is “abcdefghijklm noprs??.

• Assume that “root1?? is a child of “root?? having “changeCommands?? field

“c2*;c4?;d5;c12!??.

• “;?? separates the commands.

• “changeCommands?? field equal to “#?? string means no modification on the

parent.

• The content of “root1?? is “ab*d?ghijklm!noprs??

• “c2*?? means change the second index of the string to '*'.

• “d5?? means delete the fifth index of the string.

• Warning: Each operation is executed on the string which is created as a result

of the previous operation. Therefore, the index values represent the indexes on

the new string.

Important: While you are implementing the operate function, you will need many

functions in order to use in operate. You will write them into the class “VersionHelper??

which will be declared in “version_helper.h?? and implemented in “[url removed, login to view]?.

As this class is a friend class for both “VersionTree?? and “SourceFile?? classes, it can

access all the elements of both classes. You will also be able to call the functions in

“VersionHelper?? class from the operate function by including "version_helper.h" into

“[url removed, login to view]?.

Important: There will be no error in the syntax of the given command. The syntax will

always be given in the form of this homework definition. But, there may be error in its

semantic. In all of the commands, if any version given by its name does not exist in the

tree, the command should do nothing. You should take this situation into account.

• The files which will be helpful for you:

• main.h

#ifndef _MAIN_H

#define _MAIN_H

#include "versioner.h"

class Main {

public:

Main();

};

#endif

• [url removed, login to view]

#include "main.h"

Main::Main() {

SourceFile f("/home/samet/[url removed, login to view]", "12/10/2008");

[url removed, login to view]();

}

• [url removed, login to view]

#include "main.h"

int main()

{

Main m;

return 0;

}

• The compilation will be done as follows:

“g++ -lm -ansi [url removed, login to view] [url removed, login to view] [url removed, login to view] [url removed, login to view]?

• Warning: Main class will be implemented by me. So, it can be changed. Above is a simple example.

Input/Output and runtime examples

• Assume that the content of the file [url removed, login to view] is “abcdefghijlm norstuvyzw??.

Command line is:

16

addVersion root root-1 14/10/2009 c4?;

addVersion root root-2 15/10/2009 c11p;d13;d10;c5k;

addVersion root root-3 16/10/2009 c12p;d13;d7;c6k;

addVersion root root-4 17/10/2009 c13p;d13;d3;c4k;

addVersion root-1 root-1-1 18/10/2009 c2*;d0;d1;c5!;

addVersion root-1 root-1-2 19/10/2009 c15p;d13;d2;c11k;

addVersion root-2 root-2-1 20/10/2009 c16p;d13;d11;c12k;

addVersion root-1-1 root-1-1-1 21/10/2009 c17p;d13;d8;c14k;

addVersion root-1-1 root-1-1-2 22/10/2009 c7-;d8;

deleteVersion root-1

deleteVersion -r root-2

printVersionTree dfs

printVersionTree bfs

printVersionNumber root-1

printVersionNumber root-1-1-2

printVersionContent root-1-1-2

Result:

root 12/10/2008 #

root-1-1 18/10/2009 c4?;c2*;d0;d1;c5!;

root-1-1-1 21/10/2009 c17p;d13;d8;c14k;

root-1-1-2 22/10/2009 c7-;d8;

root-1-2 19/10/2009 c4?;c15p;d13;d2;c11k;

root-3 16/10/2009 c12p;d13;d7;c6k;

root-4 17/10/2009 c13p;d13;d3;c4k;

root 12/10/2008 #

root-1-1 18/10/2009 c4?;c2*;d0;d1;c5!;

root-1-2 19/10/2009 c4?;c15p;d13;d2;c11k;

root-3 16/10/2009 c12p;d13;d7;c6k;

root-4 17/10/2009 c13p;d13;d3;c4k;

root-1-1-1 21/10/2009 c17p;d13;d8;c14k;

root-1-1-2 22/10/2009 c7-;d8;

1.1.2

bd?fg!i-m norstuvyzw

Evaluation:

• Tar three files (“[url removed, login to view]?, “version_helper.h?? and “[url removed, login to view]?) and give the name “[url removed, login to view]?

and submit this file.

• Your code should be compiled on inek machines with the compiler g++.

g++ -lm -ansi [url removed, login to view] [url removed, login to view] [url removed, login to view] [url removed, login to view]

• Your code will be evaluated with black box. So be sure to obey input/output specifications.

Evner: Ingeniørarbejde, MySQL, PHP, Projekt Ledelse, Software Arkitektur, Software Testning

Se mere: write a recursive function, working from home job search, working from home data input, working at h&m, white and black tree, which company need a engineer, using stl, uses of tree data structure, uses of stack in data structure, uses of stack data structure, uses of data structure, use of trees in data structure, use of tree data structure, two string problem, tree update, tree traversal in data structure with example, tree to box, tree structure in c, tree starting with n, trees structure

Om arbejdsgiveren:
( 7 bedømmelser ) Turkey

Projekt ID: #3043711

ovidiuv

See private message.

$85 USD in 3 dage
(246 bedømmelser)
5.6