Changes

Jump to: navigation, search

Project A3 20141 - OOP344

4,299 bytes added, 10:22, 3 April 2014
m
no edit summary
{{OOP344 Index Extended | 20141}}
 
= Introduction =
Our third In this assignment , you will have you construct an integer holding linked list, adapt it into a templated linked list, then create an a '''bonus''' object editor utilizing the list. You will use the testing package linked [http://replace.me here] to test your assignment. The linked lists have automated tests; the rest of the assignment has some automated tests and some visual tests. Please note the filename and test number conveniently provided in the section headers for each required class/function.
; SANITY NOTE== Testing ==Use the testing package linked [https: You will be writing a number of classes and functions//scs.senecac.on.ca/~hasan.kamal-al-deen/public_resources/oop344/a3test_apr032014. Please remember zip here(Updated April 3 2014)] to '''sanitize''' test your code as you go alongassignment.; What is code sanity?: The idea behind code sanity is to keep Please read the code clean and the logic strong '''at all times'''notes/comments in a3test. This has 2 main advantagescpp.# If your code is logically correct '''at all times''' then you can be sure that if there is a problem, it has been caused by the latest set of alterations.# It makes debugging '''much much easier''' both for yourself and for '''anyone helping you'''== Expectations ==; So how do I keep my code sane?: By following these 2 simple steps:# Keep the code nicely '''formatted''' at '''all times'''. This makes it easy to see the logical structure of your program Test numbers are provided at a glance and to follow the logic of it. Experienced programmers do '''NOT''' look for lines end of codeeach class spec heading, they look for '''blocks''' denoted by '''indents'''as are file names. Train yourself to do the same.<br/>'''NOTE:''' If you are using an editor or environment that makes  [[Sanity_20141_-_OOP344 | Please read this hard for you, '''start by getting a better environment!'''<br/>Windows and visual studio are an excellent combination and provided for free by Seneca. On Linux, your options are netbeans and sublime. The debugging experience is simpler on Windows for our assignments however.<br/>Also note, on visual studio, you can have the editor '''automatically''' format your code nicely by pressing the following combinations in sequence:<br/>'''CTRL-K, CTRL-D'''# Do not begin writing the next feature before the '''last feature''' is working! This is of '''paramount importance'''! By ensuring that your code is working ('''use the tests, specs, and your common sense!'''), you can save versions of your assignment at specific points in time and '''know''' that if a problem arises, '''it must be caused by your latest set of changes!'''SANITY]].
When you are finished the assignment, you will have created the following files:
* intlist.cpp
* list.h
 
* Will update with part 3 soon.
== Part 1: Integer Linked List ==
For Build the classes IntList and IntListNode. Place the headers in intlist.h and the implementation in intlist.cpp. These classes form an integer linked list. === Class: IntListNode, Files: [intlist.h, intlist.cpp], Test Number: 0 ===Integer linked list node. Node is considered last in the list if its next pointer is NULL. Note the public and protected sections below. You may need to make IntList a friend of this partclass. ==== Recommended Members ====* An integer member to hold the node's value.* A pointer to the next node in the list. ==== Public Functions ====; Constructor: Accepts two arguments::* Integer to initialize node's value. Defaults to a default constructed int.:* Pointer to next node in list. Defaults to NULL.; Copy Constructor: Initializes internal value as a copy of the source's internal value. Sets this object's next pointer to NULL.; Standard Assignment Operator: Assigns source's internal value to the current object's internal value. Sets this object's next pointer to NULL. Does not alter the object in the case of self-assignment. Returns a reference to the current object. ; val: Val getter. Const function. Does not accept parameters. Returns internal value.; val: Val setter. Receives an int. Sets internal value to received int. Does not return anything. ; next: Next getter. Const function. Does not accept parameters. Returns pointer to the next node. === Class: IntList, Files [intlist.h, intlist.cpp], you will build Test Number: 0 ===Integer linked list. Uses IntListNode as a node class. ==== Recommended Members ====* Pointer to head node in list* Current size (number of nodes) of list ==== Public Functions ====; Constructor: Does not accept parameters. Initializes list to safe empty state. ; size: Size getter. Const function. Does not receive parameters. Should return number of nodes in list.; head: Head getter. Const function. Returns pointer to head node in list. ; push: Adds a new node to the '''end of the classes list'''. I'll say that again, 'IntList''END OF THE LIST' and ''. Receives an int parameter. The new node'IntListNodes value should be set to the received int.; pop: Destroys the ''' last node in the file list'''. I'll say that again, '''LAST NODE IN THE LIST'''intlist.hDoes not receive any arguments. Does not return anything.; clear: Removes all nodes in the list. Has no effect if the list is empty. Does not accept parameters. Does not return anything. ; Destructor: Should ensure that all memory allocated by the list has been deallocated. You are encouraged to use the functions available to you. ; Standard Assignment Operator: Clears this list of all nodes. Then, refills list with the same number of nodes as in the source list. Value of each new node should equal the value of corresponding node in source list. Should not alter object in the case of self-assignment. Should return a reference to the current object.; Copy Constructor: Initializes object to safe state then copies source list into current list. Similar to assignment operator. == Part 2: Templated Linked List =='''NOTE:'''Finish part 1 before working on this part.  Build the templated linked list node class ListNode<T> and the templated linked list class List<T> in the file list.h. These two classes compose are almost identical to IntListNode and IntList, except that they are templated. In the specs below, note the sections that are marked <big><u><i>Important</i></u></big>. Those sections will have more than just a basic implementation template parameter change from the int version of an integer linked the list. === Class: ListNode<T>, Files: [list.h], Test Number: 1 ===Templated ListNode class. Similar to IntListNode but templated to hold any type. The syntax for prototyping a templated class is: template <typename T> SomeClass; ==== Recommended Members ====* Template type member to hold the value.* Pointer to next node in list. ==== Public Functions ====These functions are similar to their IntListNode counterparts. ; Constructor: Accepts two arguments.:* <big><u><i>Important</i></u></big> const T reference to initialize node's value. Defaults to a default constructed T.:* Pointer to next node in the list. Please see Defaults to NULL.; Copy Constructor: Initializes internal value as a copy of the source's internal value. Sets this object's next pointer to NULL.; Standard Assignment Operator: Assigns source's internal value to the following sections on current object's internal value. Sets this object's next pointer to NULL. Does not alter the object in the exact specifications case of these classesself-assignment. Returns a reference to the current object.
=== Class; val: IntListNode, Files: [intlistVal getter. Const function. Does not accept parameters.h, intlistReturns internal value.cpp], Test; val: 0 ===An IntListNode is Val setter. <big><u><i>Important</i></u></big> receives a linked list node, as such it holds an integer const T reference. Sets internal value and a pointer to an IntListNode that is the next node in the list. If the next link is NULL then the current node is considered the '''last node in the list'''received reference. While this class is only used by IntList, it is expected to have a set of its own functionalityDoes not return anything. The exact specs follow:
; next: Next getter. Const function. Does not accept parameters. Returns pointer to next node. ===Class: List<T>, Files [list.h], Test Number: 1 = Protected Functions ==A templated linked list class. Similar to IntList. Uses ListNode<T> as a node class. ==== Recommended Members ====* Pointer to head node in list; void next* Current size (IntListNode*number of nodes): Setter function for the '''next''' property. Sets the internal next pointer held by this node to the incoming value.of list
==== Public Functions ====
*; Constructor: Does not accept parameters. Initializes list to safe empty state. ; size: Size getter. Const function. Does not receive parameters. Should return number of nodes in list.; head: Head getter. Const function. Returns pointer to head node in list. ; push: Adds a new node to the '''end of the list'''. I'll say that again, '''END OF THE LIST'''. <big><u><i>Important</i></u></big> receives a const T reference. The new node's value should be set to the received reference.; pop: Destroys the '''last node in the list'''. I'll say that again, '''LAST NODE IN THE LIST'''. Does not receive any arguments. Does not return anything.; clear: Removes all nodes in the list. Has no effect if the list is empty. Does not accept parameters. Does not return anything. ; Destructor: Should ensure that all memory allocated by the list has been deallocated. You are encouraged to use the functions available to you. ; Standard Assignment Operator: Clears this list of all nodes. Then, refills list with the same number of nodes as in the source list. Value of each new node should equal the value of corresponding node in source list. Should not alter object in the case of self-assignment. Should return a reference to the current object.; Copy Constructor: Initializes object to safe state then copies source list into current list. Similar to assignment operator. == Submission ==Please only submit '''ONCE YOUR CODE SUCCESSFULLY PASSES ALL TESTS!''' This includes the '''COMMON SENSE TEST''' which is the test that you perform '''yourself''' on your own code to ensure that it matches with what is required in the spec. ; Section A, C: Please submit via blackboard.; Section B: Please see your instructor's specific instructions on how to submit.

Navigation menu