<last updated
PREREQUISITE: CSC1142 (intro to programming - C++).
TEXT: Main Text: Object Oriented programming Using C++/2nd
edition
Supplementary Text: ECKEL VOL 1 (online)
ch1 ch2 ch3 ch4 ch5 ch6 ch7 ch8 ch9 ch10 ch11 ch12 ch13 ch14 ch15 ch16
ECKEL VOL 2 (not operational)
ch1 ch2 ch3 ch4 ch5 ch6 ch7 ch8 ch9 ch10 ch11 ch12 ch13 ch14 ch15 ch16
AUTHOR: Joyce Farrell
SOFTWARE: Microsoft Visual C++ 6.0
GRADING:
- quizzes (4 - 5):....................................... 50%
- final exam and/or project:..................... 30%
- labs (approx. 8 - 10):.............................. 20%
NOTE: all chapters refer to the main text,
unless otherwise indicated.
LECTURE:
PAGES:
HIGHLIGHTS: .Overview of OOP (Object
Oriented Programming);
LAB: lab 1
LECTURE: ch 2; ch. 3
PAGES:
HIGHLIGHTS: C++ Review ; Arrays;
Strings; Pointers
LAB: lab 2
LECTURE:
PAGES:
HIGHLIGHTS: review of Functions; overloading
functions
LAB: lab 3
LECTURE: ch. 5; also see Eckel
ch1
PAGES:
HIGHLIGHTS: using CLASSES; data hiding
& encapsulation; private functions;
LAB: lab 3b
LECTURE: ch 5 (continued);review for exam 1
PAGES:
HIGHLIGHTS: static class
members;
LAB: lab 4A
LECTURE: EXAM 1 (ch 1-5 & lectures); ch 6
PAGES:
HIGHLIGHTS: constructors;
LAB:
lab4b
LECTURE:
ch 6 continued
PAGES:
HIGHLIGHTS: Composition; cohesion; coupling;
function classifications
LAB:
lab4c
LECTURE:
Review ch 6;. -
PAGES:
HIGHLIGHTS:
LAB: lab 4d
WEEK 9 (
LECTURE: Wed:Mid-Term Exam – ch 1-6
PAGES: : ch 9
HIGHLIGHTS: Inheritance
LAB:
LECTURE: ch. 9
PAGES.
HIGHLIGHTS: Inheritance:
basics; access modifiers; constructor initialization list; base class
construction
LAB: lab 5v3 due; start lab 6v1
LECTURE: ch. 8;
HIGHLIGHTS: overloading operators: math operators;
input/output operators
LAB: lab 6v1due;start lab 6v2
LECTURE:
Polymorphism
PAGES: pp. 269-290
HIGHLIGHTS:
LAB:
lab 6v2 due
LECTURE: WED Quiz on Inheritance
PAGES:
HIGHLIGHTS:
LAB:
start lab 6v3
LECTURE:
Templates
PAGES: ch. 11
HIGHLIGHTS:
LAB:
WEEK 15(12/2&4/02)
LECTURE: Templates (continued); review for final
PAGES:
HIGHLIGHTS:
LAB: lab 7
LECTURE: Mon: review for
final; Wed Final Part I;
Thurs Final Part
III
PAGES:
HIGHLIGHTS:
LAB:
LECTURE: Mon: Final Part II
PAGES:
HIGHLIGHTS:
LAB:
1. Create a class called rectangle.
a. Data Members (attributes): length;
width.
b. Methods (operations): area; perimeter; initialize; display
c. Make the methods public
and the data members private.
d. The area and perimeter
methods should be implemented as value-returning
functions.
e. The display method will display the data members of a given
object and
also the area and perimeter.
2. Create client code that uses
the class.
a. Create an array of
rectangle objects.
b. Initialize the
array of objects by reading data from a disk text file.
c. Loop through the
array of objects and display each one.
LAB #2
Extend lab 1:
a. Use an array of pointers instead of an array of objects; and
make the necessary
adjustments.
b. Replace the initialize method with a constructor(s) method.
LAB #3
Extend lab 2:
Divide lab 2 into 3 separate files: header;
implementation;
client
LAB #3B
General:
Extend lab 3 by physically hiding the implementation
source code.
Directions:
LAB #4A
General:Create a class called list and implement it as an array.
Directions:
1. Data Members:
- array of integers
- size of array
- cursor (indicates the next
position in the list available for a get)
- end_position (indicates the next
position in the list available for a
put)
2. Member Functions:
- list(): constructor - initializes
the list’s data members.
- clear(): clears the list.
- put(int): places an item (received
from the client) on the list.
- get(int&): retrieves an item
from the list and passes it to the client.
- cursor_position(int): resets cursor
position based on client input.
3. Processing:
- get():, Using
the current value of the cursor as an index, the
get()
function retrieves an item from the
list and passes it to the client; the
cursor is advanced to
the next position in the list; returns a false
if the cursor equals the
end_position or the end of the list.
- put(): Using
the current value of the end_position as an index, an
item received from the client is
placed on the list; the end_position
is advanced to the next position in
the list; returns a false if the
end_position indicates a full list.
- clear(): The cursor
and end_position are both set to zero.
LAB #4B
General:
Extend lab4A: the data type of the array will
become generic; it will be
determined by the client.
Directions:
1. The client will define the data type of the array using a separate .h file -
call it list_item.h, which
will contain the following:
struct itemType
{
// Client
defines any data type in the form of a struct
int id;
string name;
};
2. Include list_item.h in list.h.
3. All references to the data type of the list element (array item) will be
replaced with itemType.
Example: void list::put(itemType)
4. The client will reference list items as seen in the following client
excerpt:
list lst;
itemType item;
item.id=200;
item.name=”Smith”;
lst.put(item);
LAB #4C
General:
Extend lab4b: the size of the array will be
determined by the client.
Directions:
1. The array data member will be declared in a manner that will
facilitate
a dynamic array.
2. The client will pass the size of the array when a list object
is
declared.
3. The constructor will dynamically allocate the array space
using
the new operator.
LAB #4D
General:
Create a client that uses the list
and the rectangle classes
to create
a list of rectangles.
Directions
- Include the rectangle class
in your list_item.h file.
- The item type of your list will be a
rectangle.
- Display the area and perimeter of
each rectangle in the list.
LAB #5
General Description:
A company has two types of employees - salaried and hourly.
Each employee has an id number and last name. The salaried workers have yearly
salary information, and the hourly workers have an hourly rate and weekly hours
worked information. The company computes the weekly wages for
each type of employee. In addition, the company estimates the annual
salary for each employee: for salaried employees it is simply
their annual salary; for hourly employees it is 52 time s 40 times their hourly
rate.
Directions:
LAB #6 V2
Extend lab 6v1 to include overloading the
+ operator as a means of increasing
an employee’s
pay rate.
LAB #6 V3
Extend lab 6v1 to include polymorphism.
LAB #7
General Description:
Extend lab 4: Use templates instead
of list_item.h as a means of allowing different data types to be
used as elements of the list (array).
Directions:
1. Test the lab by creating a client that uses 2 lists, each one being
a different data type; make one data type a struct.
2. Display each list.
**************************************************************
LAB #cards
DIRECTIONS:
1.
Download: card.h; card.obj
from: ----------------savas/csc2220/card
2. Write a client program that instantiates an array of 5 card object pointers.
3. Display the objects using the display() method.
4. Determine if the 5 cards are a full-house.
Full house = 3 of one value and 2 of another value.
EXAMPLES: three 9’s and two 4’s; three 6’s and two 8’s.
5. SUGGESTION: use the getvalue() method to create an array of card values, and then evaluate the array to determine if it is a fullhouse.
LAB cards/V2
(lab cards Version 2)
GENERAL
DESCRIPTION:
Lab 4 will be extended to include a hand class. The hand class
will be composed of the card class . The client
will instantiate the hand(s) objects;
the hand class will instantiate the card objects. The hand class will evaluate
hands for the following:
1. Full-house
2. Two of a kind
3. Three of a kind
4. Four of a kind
DIRECTIONS: