代写C++ | Project | Data Structure代写 | 作业Assignment – CS24 project

代写C++|Project|Data Structure代写|作业Assignment – 这是一个利用C++进行的数据结构方面的任务代写

CS24 project 1

Objectives : This project is the first project you will be working on this quarter. There are a number of objectives to this assignment. First, to start gaining experience in developing programs in C++. Second, because you are allowed to use any references you find online, this assignment will help you get a sense for just how many sources for programming in c++ are available via the web. Project specification : In this project you are going to implement a word search engine using C++. The search engine would help users to count number of occurrences of a word among given set of text files. Input specification : The program takes as an input a set of files, containing multiple words. Words can appear multiple times in a single file or in different files. The input files are assumed to be stored in a dedicated directory (for e.g. /cs/class/cs24/project1/input) and loaded in memory upon program execution. Use the driver program given, to return a list of (word count,file) from the list of input files. Program functionality : Upon execution, the program should load all the words from the input files in the memory. The program should run until the user explicitly specifies exit. The following functionality should be supported:

  1. Count how many times a user specified word appears in the files.
  2. Display the name of input files and corresponding number of occurrences of the specified word. Upon execution of your program, you should specify as input parameter the path to a directory containing the input files. Below you can find the format specification: $./wordsearch <path_to_input_files> Examples for execution format: $./wordsearch /cs/class/cs24/project1/input Enter word: cat If executed as specified above, the program should return the name of files that contain word cat and the number of occurrences of the word in each file Implementation requirements : First, you need to implement a class for an abstract data type, in which you are going to store files in memory. For the current implementation you are required to use an array to store the list of words. A basic layout of the Data structure you would need to implement is illustrated on the figure below:

.

.

.

.

You need to declare a class Word that would store a word and a reference to a bag object that contains the list of files containing that word, along with the number of occurrences. To do this, create another class File that would store a file-name and number of times that the word occurred in this file. You may assume the maximum number of files to be 100 and the maximum number of words to be 1000. The process of loading files in the memory consists of (i) creating an object of type Word for each new word that occurs in the set of input files, (ii) appending this object to an array(e.g. the green array from the picture), (iii) creating an object File for each occurrence of the word in a file and (iv) updating the corresponding (blue) bag with the objects of type File. Once you have the files loaded in such structure, the searching would be as easy as finding the queried word in the green array and tracing in which files does it occur by going over the corresponding blue bag.

To start gaining experience in how to structure your C++ projects, you are required to split the different aspects of this program and implement them in separate files. Then you will have to put them all back together to achieve the program functionality. By now, you should be familiar with the concept of .h and .cpp files (if not, it is a good moment to familiarize yourselves). You will need to create several .h and .cpp files for this project. We will help guiding you through this process. First you need to identify the important object-types and methods you will need for your implementation. In this project, your main object types are going to be class Word and class File. Go ahead and create a file called itemtype.h and declare class File in it. Then create another file called itemtype.cpp and define your class File in it. These two files are going to be related to objects from the blue bags on the picture. The next step is to implement the functionality for creating the blue bags. For this purpose, you need to create two more files bag.h and bag.cpp. In bag.h declare all the methods needed for building a blue bag and in bag.cpp define these methods. Next, you need to implement the functionality related to objects like those in the green array. Create two more files word.h and word.cpp, declare class Word and all methods to this class in word.h and define them in word.cpp. Now what’s left is to put it all together by writing a main function that utilizes both file and word. To do so, create wordsearch.h and wordsearch.cpp, declare your main function in wordsearch.h and define it in wordsearch.cpp. So all in all you will need eight files: wordsearch.h, wordsearch.cpp, itemtype.h, itemtype.cpp, bag.h, bag.cpp, word.h, word.cpp. Instructions for compilation: Your program should compile on a CSIL machine with the following command without any errors or warnings. $ g++ -o wordsearch wordsearch.cpp itemtype.cpp bag.cpp word.cpp Submission instructions : Please read carefully and follow the submission instructions. Name your files as specified and follow the requested format. An automated grading will be performed and failure to follow the format for submission will result in points being taken off from your grade. You need to submit 8 files namely wordsearch.h, wordsearch.cpp, itemtype.h, itemtype.cpp, bag.h, bag.cpp, word.h, word.cpp. Turn-in procedure : Upload your files to gauchospace under the corresponding project submission folder.

发表评论

电子邮件地址不会被公开。 必填项已用*标注