Find Jobs
Hire Freelancers

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

$10-30 USD

Cancelado
Publicado hace alrededor de 8 años

$10-30 USD

Pagado a la entrega
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 del proyecto: 9725964

Información sobre el proyecto

Proyecto remoto
Activo hace 8 años

¿Buscas ganar dinero?

Beneficios de presentar ofertas en Freelancer

Fija tu plazo y presupuesto
Cobra por tu trabajo
Describe tu propuesta
Es gratis registrarse y presentar ofertas en los trabajos

Sobre este cliente

Bandera de UNITED STATES
Davis, United States
5,0
1
Forma de pago verificada
Miembro desde feb 11, 2016

Verificación del cliente

¡Gracias! Te hemos enviado un enlace para reclamar tu crédito gratuito.
Algo salió mal al enviar tu correo electrónico. Por favor, intenta de nuevo.
Usuarios registrados Total de empleos publicados
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Cargando visualización previa
Permiso concedido para Geolocalización.
Tu sesión de acceso ha expirado y has sido desconectado. Por favor, inica sesión nuevamente.