Find Jobs
Hire Freelancers

Build a Small Program

$10-30 USD

Cancelled
Posted about 8 years ago

$10-30 USD

Paid on delivery
You are to write a program that reads a file that recursively lists the files in a directory. There are four classes: ListNode, List, File, and Directory. The Directory class is derived from the File class. To allow for polymorphism, the List declared in main() will hold File*, not File. As the program reads the file it will use the first letter to determine whether it should create a new Directory or new File. It then can insert into the list the pointer. For find, it will need to create a File based on the user input, and then pass the address of the File to List::find(). There is a simple way to repeatedly create such a File inside a loop without calling new. See if you can figure out how I did it. For this assignment, I am not going to give you step by step instructions for the development of the program. It is time for you to develop a program on your own. I suggest that you develop from top down using stubs. 1. main() calls a read function, and then enters a loop. main() prints the “Not found” if [login to view URL]() returns false. 2. ListNode class is a template class with both a prev and next ListNode<T> pointers. Because the T data stored is a pointer to an object that is created using new, it will be up to the destructor of ListNode to delete it. 3. List class is a template class with ListNode<T> *head, and *curr, that is sorted based on the overloaded comparison operators of the T class that compare the names of the Files. 3.1. To get things up and running, initially I would just use the List as a single linked list. However, it is worth five points of the fifty to have curr move forward and backward within the list. 3.2. Since the list knows that it will always be storing pointers as the data in the ListNodes, it will usually dereference the data when using it. Be careful when comparing dereferenced T’s that the one in the list is always on the right side of the comparison! This permits the operator of the proper class, File or Directory, to be called. 3.3. There is five points extra credit if you write both the find(), and insert() without using any additional ListNode<T> pointers, e.g. the ptr and prev used in lecture. 3.4. The methods are: a constructor, a destructor, bool find(), void insert(), and void print(). 4. File class has only a protected char *name for data that must be dynamically allocated. The code for each of the methods is no more than three lines long! 4.1. The non-virtual methods are all public: a constructor, and const char* getName(). 4.2. The virtual methods are: a destructor, bool find(), void insert(), operator==, operator<, and operator>. 4.2.1. The find() method just prints the name of the file. 4.2.2. The insert() method does nothing! 4.2.3. The comparison operators just use strcmp(). 5. Directory class is publicly derived from File, and also contains a List<File*>, named files. Thus, main’s List is actually a List of Lists! 5.1. The methods it has are: a constructor, a destructor, and versions of all the virtual methods of File. 5.1.1. find() prints the List of the Directory if it’s name is a perfect match, otherwise it calls the find of its List. 5.1.2. insert() does nothing if its name is a perfect match, otherwise it calls the insert of its List. 5.1.3. The comparison operators are used by List, and use strncmp() to compare the name of the directory with the beginning of the name of the data being compared. They are a little tricky. For example, “40/p4 == 40/p4/private” is true because the p4 is followed by a ‘/’ in the second operand, but “./handin/p4/davis == ./handin/p4/davistemp” is false because the “davis” in the second operand is neither the end of the string, nor followed by a ‘/’. [login to view URL]~ssdavis/40/[login to view URL]
Project ID: 9707779

About the project

2 proposals
Remote project
Active 8 yrs ago

Looking to make some money?

Benefits of bidding on Freelancer

Set your budget and timeframe
Get paid for your work
Outline your proposal
It's free to sign up and bid on jobs
2 freelancers are bidding on average $33 USD for this job
User Avatar
Hey, I can get this done for you in 2-3 days. I have extensive experience with C++, Java, C# coding. Am new to freelancer, hence no reviews or ratings.
$35 USD in 3 days
0.0 (0 reviews)
0.0
0.0
User Avatar
Hello, client I have rich experience in C++ /C# programming and Algorithm If you hire me, i will complete within a day Thanks
$30 USD in 1 day
0.0 (0 reviews)
0.0
0.0

About the client

Flag of UNITED STATES
Davis, United States
5.0
1
Payment method verified
Member since Feb 11, 2016

Client Verification

Thanks! We’ve emailed you a link to claim your free credit.
Something went wrong while sending your email. Please try again.
Registered Users Total Jobs Posted
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Loading preview
Permission granted for Geolocation.
Your login session has expired and you have been logged out. Please log in again.