Find Jobs
Hire Freelancers

Build a Small Program. (Need to be completed in less than 48 hours)

$10-30 USD

취소됨
게시됨 8년 이상 전

$10-30 USD

제출할때 지불됩니다
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]
프로젝트 ID: 9725964

프로젝트 정보

원격근무 프로젝트
활동 중 8년 전

돈을 좀 벌 생각이십니까?

프리랜서 입찰의 이점

예산 및 기간 설정
작업 결과에 대한 급여 수급
제안의 개요를 자세히 쓰세요
무료로 프로젝트에 신청하고 입찰할 수 있습니다

고객에 대한 정보

국기 (UNITED STATES)
Davis, United States
5.0
1
결제 수단 확인
2월 11, 2016부터 회원입니다

고객 확인

감사합니다! 무료 크레딧을 신청할 수 있는 링크를 이메일로 보내드렸습니다.
이메일을 보내는 동안 문제가 발생했습니다. 다시 시도해 주세요.
등록 사용자 전체 등록 건수(일자리)
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
미리 보기 화면을 준비 중...
위치 정보 관련 접근권이 허용되었습니다.
고객님의 로그인 세션이 만료되어, 자동으로 로그아웃 처리가 되었습니다. 다시 로그인하여 주십시오.