User Tools

Site Tools


Sidebar

projects

dsi0 (20170826)
wcp1 (20170826)
ael0 [faq] (20170830)
wcp2 (20170902)
sln0 [faq] (20170906)
wcp3 (20170909)
sln1 [faq] [metrics] (20170913)
wcp4 (20170916)
sll0 [faq] [metrics] (20170920)
wcp5 (20170923)
sll1 [faq] [metrics] (20170927)
wcp6 (20170930)
sll2 [faq] [metrics] (20171004)
wcp7 (20171007)
sll3 [faq] [metrics] (20171018)
sll4 [faq] [metrics] (20171018)
wcp8 (20171021)
dln0 [faq] [metrics] (20171025)
dll0 [faq] [metrics] (20171025)
wcp9 (20171028)
dll1 [faq] [metrics] (20171101)
wcpA (20171104)
dll2 [faq] [metrics] (20171108)
dls0 [faq] [metrics] (20171108)
wcpB (20171111)
dlq0 [faq] [metrics] (20171115)
wcpC (20171118)
dlt0 [faq] [metrics] (20171129)
haas:fall2017:data:projects:eoce1

Corning Community College

CSCS2320 Data Structures

~~TOC~~

Project: EOCE1

Errata

This section will document any updates applied to the project since original release:

  • revision 1: app/ directory files had some typos (20151205)

Objective

In this project, we pursue our third rewrite of linked list code, this time implementing such functionality within an object-oriented fashion using C++ (in true OOP form, and not as a lazy C!)

This also serves as part of the End of Course Experience, which wraps up our Data Structures journey this semester.

Background

Hopefully by now, we have all grown rather familiar with the basic concepts surrounding nodes and linking them together, and all the fun/attention to detail/number of details/variations that can offer to problem solving.

As a means of furthering our conceptual understanding, while also gaining valuable programming experience, we will now undergo a rewrite in on object-oriented fashion, pursuing more than just the superficial objects/classes that are barely a third of the object-oriented experience.

And what are the other two-thirds? Why, inheritance and polymorphism, of course!

Project Overview

For this project, we're going to be implementing a linked list data structure utilizing nodes. Predominantly one should notice many similarities of conceptual flow– since we are just re-implementing something we've done twice before.

The big differences are syntactical and object-oriented conceptual. One thing we now have to content with is access control, which adds another layer of detail to things. But that also offers us some advantages.

Also, note the case, especially as “camel case” (ie the capitalization of first letters of words, frequently words that are smashed together to form a more descriptive variable name)… this tends to be part of the object-oriented programming culture, even if it isn't required by the language proper or any of its development tools.

In inc/Node.h

First up, let's start with something that, at its core, should be quite familiar:

1
#ifndef _NODE_H
#define _NODE_H
 
#include <cstdlib>
 
class Node {
    public:
             Node();
             Node(int);
        void setValue(int);
        int  getValue();
        virtual Node *copy() = 0;
        virtual void  setAfter(Node *) { };
        virtual Node *getAfter()       { return (NULL); };
        virtual void  setPrior(Node *) { };
        virtual Node *getPrior()       { return (NULL); };
        virtual ~Node();
 
    private:
        int  value;
};
 
#endif

The OOP Node class is now part of a hierarchy, and as such, is what is known as an abstract base class… what might seem weird, is this is really only a base reference point, we won't actually be making any Node objects (we can't, nor would we want to– Node as a class isn't actually useful), but deriving child classes from this class. And we will want to instantiate those derived classes.

But- to add a twist, through C++'s ability to upcast base class pointers and taking advantage of polymorphism, we will access the child class functionality THROUGH this class, keeping the naming simpler.

In inc/SinglyLinkedNode.h

The first node class we can make use of is that of the Singly Linked Node. Here, we see that the SinglyLinkedNode class inherits from Node, and in similar style, incorporates content from its parent class, and adds new functionality (specifically, the after pointer). So, SinglyLinkedNode is similar to the nodes used in the earlier parts of the semester.

Note that, due to access control, the ability to read/write the after pointer will be restricted outside of this class. As such, we implement two accessor functions: setAfter() and getAfter(), which will do the sanctioned and heavy lifting to allow outside parties access.

1
#ifndef _SINGLY_NODE
#define _SINGLY_NODE
 
#include <Node.h>
 
class SinglyLinkedNode : public Node {
        public:
                         SinglyLinkedNode();
                         SinglyLinkedNode(int);
                virtual Node *copy();
                void setAfter(Node *);
                Node *getAfter();
                        ~SinglyLinkedNode();
 
        private:
                Node *after;
};
 
#endif

In inc/DoublyLinkedNode.h

The DoublyLinkedNode class gets our node capabilities back to how we've been dealing with them of late– a node containing a value that has 2 pointers: after and prior

Due to inheritance, we get the value element stuff from the base Node class. We then get all the after element stuff from the SinglyLinkedNode class. As a result, DoublyLinkedNode is an extension of SinglyLinkedNode, which is itself an extension of the base Node class.

1
#ifndef _DOUBLY_NODE
#define _DOUBLY_NODE
 
#include <SinglyLinkedNode.h>
 
class DoublyLinkedNode : public SinglyLinkedNode {
    public:
        DoublyLinkedNode();
        DoublyLinkedNode(int);
        virtual Node *copy();
        void setPrior(Node *);
        Node *getPrior();
        ~DoublyLinkedNode();
 
    private:
        Node *prior;
};
#endif

In inc/List.h

Now that we have the classes needed to create and manipulate nodes, we move onto classes that oversee the coordinated manipulation of nodes– referenced from a new container letting us keep track of where to begin and to end, along with how many nodes are a part of this effort. We've come to call these 'lists', due to their sequential nature.

The List class is another abstract base class, meaning we cannot instantiate it, but it will provide some of the core building blocks so that it can be inherited into derived classes and used.

1
#ifndef _LIST_H
#define _LIST_H
 
#include <Node.h>
 
class List {
        public:
                List();
 
                virtual List *copy() = 0;
                int     getQuantity();
 
                virtual void  append(Node *, Node *) = 0;
                virtual void  insert(Node *, Node *) = 0;
                virtual Node *obtain(Node *) = 0;
 
                virtual void  display(int) = 0;
                virtual Node *find(int) = 0;
 
                virtual Node *getFirst() = 0;
                virtual Node *getLast() = 0;
 
                virtual ~List();
 
        protected:
                void  setQuantity(int);
 
                virtual void  setFirst(Node *) = 0;
                virtual void  setLast (Node *) = 0;
 
                virtual Node *setListPosition(int) = 0;
                virtual int   getListPosition(Node *) = 0;
 
        private:
                int   quantity;
};
 
#endif

In inc/ListOfSinglyLinkedNodes.h

Here the ListOfSinglyLinkedNodes class is the analog to what we called a Singly-Linked List earlier in the semester. It has first and last pointers, it maintains a quantity, and it implements operations to maintain the consistency of this particular grouping of nodes (the ability to insert(), append(), and obtain() nodes in a sane fashion, along with other helpful member functions).

1
#ifndef _SINGLY_LIST_H
#define _SINGLY_LIST_H
 
#include <List.h>
#include <SinglyLinkedNode.h>
 
class ListOfSinglyLinkedNodes : public List {
        public:
                ListOfSinglyLinkedNodes();
 
                virtual List *copy();
 
                virtual void  append(Node *, Node *);
                virtual void  insert(Node *, Node *);
                virtual Node *obtain(Node *);
 
                virtual void  display(int);
                virtual Node *find(int);
 
                Node *getFirst();
                Node *getLast();
 
                virtual ~ListOfSinglyLinkedNodes();
 
        protected:
                void  setFirst(Node *);
                void  setLast (Node *);
 
                virtual Node *setListPosition(int);
                virtual int   getListPosition(Node *);
 
        private:
                Node *first;
                Node *last;
};
#endif

In inc/ListOfDoublyLinkedNodes.h

With the “List Of Doubly Linked Nodes”, we see an Object-Oriented C++ implementation of the data structure we affectionately came to know as the “Doubly Linked List”– ie a list of nodes connected to both their immediate after and prior neighbors.

1
#ifndef _DOUBLY_LIST_H
#define _DOUBLY_LIST_H
 
#include <DoublyLinkedNode.h>
#include <ListOfSinglyLinkedNodes.h>
 
class ListOfDoublyLinkedNodes : public ListOfSinglyLinkedNodes {
        public:
                ListOfDoublyLinkedNodes();
 
                virtual List *copy();
 
                virtual void  append(Node *, Node *);
                virtual void  insert(Node *, Node *);
                virtual Node *obtain(Node *);
 
                virtual void  display(int);
                virtual Node *find(int);
 
                virtual ~ListOfDoublyLinkedNodes();
 
        protected:
                virtual Node *setListPosition(int)    { return (NULL); };
                virtual int   getListPosition(Node *) { return (-1);   };
};
#endif

Project Requirements

For this project, it is your responsibility to:

  • Implement all functions in the following classes:
    • Node
    • SinglyLinkedNode
    • DoublyLinkedNode
    • List
    • ListOfDoublyLinkedNodes
  • Implement the minimally necessary amount of functions in ListOfSinglyLinkedNodes to allow ListOfDoublyLinkedNodes to work
  • Implement unit tests to check the viability of your implementations (I will supply one for analysis).
    • by unit test, I mean something rather aggressive that tests many arrangements of valid operations, to ensure correct implementation. You may model after the logic I used in the unit tests you've made use of all semester.

For those interested in an extra credit opportunity (especially to make up for a missed project), you may fully complete both the functions and create unit tests to bring the ListOfSinglyLinkedNodes class fully on-line.

Submission

Project Submission

When you are done with the project and are ready to submit it, you simply run make submit:

lab46:~/src/data/PROJECT$ make submit
...

Submission Criteria

To be successful in this project, the following criteria must be met:

  • Project must be submit on time, by the posted deadline.
    • Early submissions will earn 1 bonus point per full day in advance of the deadline.
      • Bonus eligibility requires an honest attempt at performing the project (no blank efforts accepted)
    • Late submissions will lose 33% credit per day, with the submission window closing on the 3rd day following the deadline.
      • To clarify: if a project is due on Wednesday (before its end), it would then be 33% off on Thursday, 66% off on Friday, and worth 0% once it becomes Saturday.
      • Certain projects may not have a late grace period, and the due date is the absolute end of things.
  • all requested functions must be implemented in the related library
  • all requested functionality must conform to stated requirements (either on this project page or in comment banner in source code files themselves).
  • Output generated must conform to any provided requirements and specifications (be it in writing or sample output)
    • output obviously must also be correct based on input.
  • Processing must be correct based on input given and output requested
  • Project header files are NOT to be altered. During evaluation the stock header files will be copied in, which could lead to compile-time problems.
  • Code must compile cleanly.
    • Each source file must compile cleanly (worth 3 total points):
      • 3/3: no compiler warnings, notes or errors.
      • 2/3: one of warning or note present during compile
      • 1/3: two of warning or note present during compile
      • 0/3: compiler errors present (code doesn't compile)
  • Code must be nicely and consistently indented (you may use the indent tool)
    • You are free to use your own coding style, but you must be consistent
    • Avoid unnecessary blank lines (some are good for readability, but do not go overboard- double-spacing your code will get points deducted).
    • Indentation will be rated on the following scale (worth 3 total points):
      • 3/3: Aesthetically pleasing, pristine indentation, easy to read, organized
      • 2/3: Mostly consistent indentation, but some distractions (superfluous or lacking blank lines, or some sort of “busy” ness to the code)
      • 1/3: Some indentation issues, difficult to read
      • 0/3: Lack of consistent indentation (didn't appear to try)
  • Unless fundamentally required, none of your code should perform any inventory or manual counting. Basing your algorithms off such fixed numbers complicates things, and is demonstrative of a more controlling nature.
  • Code must be commented
    • Any “to be implemented” comments MUST be removed
      • these “to be implemented” comments, if still present at evaluation time, will result in points being deducted.
    • Commenting will be rated on the following scale (worth 3 total points):
      • 3/3: Aesthetically pleasing (comments aligned or generally not distracting), easy to read, organized
      • 2/3: Mostly consistent, some distractions or gaps in comments (not explaining important things)
      • 1/3: Light commenting effort, not much time or energy appears to have been put in.
      • 0/3: No original comments
      • should I deserve nice things, my terminal is usually 90 characters wide. So if you'd like to format your code not to exceed 90 character wide terminals (and avoid line wrapping comments), at least as reasonably as possible, those are two sure-fire ways of making a good impression on me with respect to code presentation and comments.
    • Sufficient comments explaining the point of provided logic MUST be present
  • Code must be appropriately modified
    • Appropriate modifications will be rated on the following scale (worth 3 total points):
      • 3/3: Complete attention to detail, original-looking implementation- also is not unnecessarily reinventing existing functionality
      • 2/3: Lacking some details (like variable initializations), but otherwise complete (still conforms, or conforms mostly to specifications), and reinvents some wheels
      • 1/3: Incomplete implementation (typically lacking some obvious details/does not conform to specifications)
      • 0/3: Incomplete implementation to the point of non-functionality (or was not started at all)
    • Implementation must be accurate with respect to the spirit/purpose of the project (if the focus is on exploring a certain algorithm to produce results, but you avoid the algorithm yet still produce the same results– that's what I'm talking about here).. worth 3 total points:
      • 3/3: Implementation is in line with spirit of project
      • 2/3: Some avoidance/shortcuts taken (note this does not mean optimization– you can optimize all you want, so long as it doesn't violate the spirit of the project).
      • 1/3: Generally avoiding the spirit of the project (new, different things, resorting to old and familiar, despite it being against the directions)
      • 0/3: entirely avoiding.
    • Error checking must be adequately and appropriately performed, according to the following scale (worth 3 total points):
      • 3/3: Full and proper error checking performed for all reasonable cases, including queries for external resources and data.
      • 2/3: Enough error checking performed to pass basic project requirements and work for most operational cases.
      • 1/3: Minimal error checking, code is fragile (code may not work in full accordance with project requirements)
      • 0/3: No error checking (code likely does not work in accordance with project requirements)
  • Any and all non-void functions written must have exactly 1 return statement
    • points will be lost for solutions containing multiple return statements in a function.
  • Absolutely, positively NO (as in ZERO) use of goto statements.
    • points will most definitely be lest for solutions employing such things.
  • No custom global variables! The header files provide all you need.
    • Do NOT edit the header files.
  • Track/version the source code in a repository
  • Filling out any submit-time questionnaires
  • Submit a copy of your source code to me using the submit tool (make submit will do this) by the deadline.
haas/fall2017/data/projects/eoce1.txt · Last modified: 2016/09/10 16:03 by 127.0.0.1