Algoma University College
COSC 1047 -
INTRODUCTION TO COMPUTER SCIENCE II
Winter 1996/97 -
Monday and Wednesday 5.30 PM
Assignment #2
INSTRUCTOR: Pawan J. Lingras
-
Create a class called user_type with three data members of the type
string called:
username, first_name, last_name.
A constructor that accepts
first_name and last_name as parameters.
The username is created by taking the first two
characters of first_name followed by first six characters of last_name.
If last_name is shorter than six characters, entire last_name is used.
Provide three additional functions to return the three data members called:
get_username(), get_first_name(), get_last_name().
Test your user_type using a small driver program.
- Overload input and output operators for the user_type.
Test the operators by modifying the driver program.
-
Create a type called database which contains the following
data members:
an array of user_type,
number of records in the database.
The access function members include:
database();
int size();
void append(user_type u);
user_type operator[](int i);
Constructor initializes the number of records to zero.
size() returns the number of records.
append() appends u at the end of the database.
The index operator returns i-th record.
Write a small driver program to test all the member functions.