Assignment #4
CS 162: Introduction to Computer Science
Submit your assignment to the D2L Dropbox
Email a backup copy to karlafgr@cs.pdx.edu
***Assignments in
CS162 consist of written homework and programming***
1)
Test Plan: For Program #4 – create
a test plan of all of the values that the user should type in to test out the
different conditions in this program. The test plan should make sure that every
line of code ends up getting executed and all boundary conditions tested. It
should make a list of all of the types of information the user should enter and
what the expected results will be. I
would suggest building a table such as this:
Test Case(s) |
Expected Result |
Verified Results |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2) Ethics. There are many aspects of computer ethics. Discuss
the ethical implications of not creating a test plan for a software application
(such as turbotax or some other commonly used
application). For Write 5 complete sentences with your thoughts.
3) Terminology. Understanding computer science
terminology is an important part of communicating with others in the field.
Define the following terms and then find 3 other terms that haven’t been used
in lecture and define them in your own words.
a. Dereferencing
b. Precedence and Associativity
c. Pointer Arithmetic
d. Boundary Conditions
e. Dynamic Memory
f. Deallocating
4) Programming. The purpose of the 4th program is to
implement the new concepts learned which include (a) pointers, (b) dynamically allocated arrays, and
(c) classes. Our
goal is to continue to create programs with a small main function that
delegates to a series of functions where the real work takes place. In this
programming assignment, you are not
allowed to use global variables. You are allowed (as usual) to use the cstring library (e.g., strlen, strcpy, and strcmp). Limit your
main (and all functions)
to no more than 20 statements of code (for executable statements… not counting variables, comments, or lines with only curly brackets).
To get full credit for the programming
portion, you will need to:
1.
Turn in an algorithm written using full English
sentences (it may be provided in outline form, paragraph form, or graphical
(such as a data flow diagram)). It can be supplied as part of your header comments
or as a separate file.
2.
Program using a consistent style of indentation,
header comments for each function, inline comments for each major block of code
3.
Make sure to put your name in your program
4.
Submit an electronic copy of your .cpp file as an attached file to the
dropbox on D2L (go to: http://d2l.pdx.edu/ to login). Make
sure to hit the submit button after uploading your files (otherwise they will
be lost)
5.
As a backup, please also email your work (as
attached file(s)) to karlafgr@cs.pdx.edu
Program
Assignment:
Have you ever used e-bay or
craigslist? On craigslist you can find cars, trucks, apartments for rent,
furniture and even free stuff. It is an online classified system. For example,
a 2000 Jaguar was just posted. Sounds interesting (not!).
With our 4th program, we will be creating software that will store
in memory information that someone wants to sell or offer and then the user can
lookup about each of the items. This program would
make the most sense with external data files, but that is NOT required. Instead,
we want to get used to the notion of classes, pointers, and dynamic memory as
our primary focus with this assignment. External data files are optional.
The type of information you will be
storing about information is:
1. Type of posting (job, housing, item for
sale, free stuff (you may modify this list))
2. Posting title
3. Posting description
4. Location
5. Contact email
6. For a job: Compensation
7. For housing: Rent, # bedrooms, square
ft.
8. For items for sale: cost
Then, create
a class called “Posting” which should support an individual posting of a given
type (jobs, housing, items for sale, or free stuff). Your class should at a minimum have this
format:
class Posting
{
public:
Posting();
~Posting();
void Create_Posting(char title[]); // create a new posting of
this title. The rest of the information should be read from the user
void Display_Posting();
bool
is_Type(char type[]); //is the posting a job,
housing, item for sales or free stuff (you can modify the argument list)
private:
//put the information about an
individual posting here
};
You must have at least TWO dynamically allocated arrays used in this Posting
class!
Once you get
this to work, add the next layer to provide for a collecting of postings! Let’s
call this a list class. We will start by using an array of postings. In Program
#5 this will change to use a linear linked list.
class List
{
public:
List();
~List();
void
Add(char title[]);
void Display_All();
void Display_Type(char type[]); //only display those postings
that match a type
private:
//put the information about an array of
postings
//and an integer count of the number of
postings available
};
***You are always welcome to do more! But, really focus
on making general purpose functions that can be re-used. Anytime you have code
that has already existed elsewhere in your program (such as to error check
input or give the user another chance), write a function instead!
Things
you should know...as part of your program:
1.
Make
sure to prompt the user for any input requested. Make sure it is clear from
your prompts what the user is expected to do.
2.
The
program should continue until the user wants to quit. Allow them to continue
until they are done.
3. You
may not use any global variables in this program!
4. You
may not use the string class – instead use arrays of characters.
5.
You
will need to read using the 3 argument version cin.get
for many of the items so make sure to use cin.ignore
to remove extra characters (and the delimiter) from the input stream.
6. Error
check for faulty input (such as negative costs and compensations). You can
assume the grader will enter in the appropriate data type if your prompts are
clear.
7. Please
make sure to Capitalize the first character of animal
names (Dragonfly Dude!!)
8.
FUNCTIONS
are required for this assignment.
On
the due date, turn in:
1. Submit your assignment to the D2L Dropbox (sign on via http://d2l.pdx.edu/)
2. Email a backup copy to
karlafgr@cs.pdx.edu
3. Remember to turn in an algorithm with your programming portion. It is worth 20% of your
program grade.
4. And,
don’t forget to add comments
and to work on your program’s readability; this is another 20%!!