Object and Generic Programming in C++ Laboratory Exercise 1 (Week 2) Solution

$35.00 $24.00

                          Task: Functions and File I/O (1.0)   Define a structure Pet consist data fields: status (lost or found), pet type, gender, breeds, age of year, age of month, colour, chip number, location, contact phone number in a file pet.h. Define functions’ prototypes…

You’ll get a: . zip file solution

 

 
Categorys:

Description

5/5 – (2 votes)

 

 

 

 

 

 

 

 

 

 

 

 

 

Task: Functions and File I/O (1.0)

 

Define a structure Pet consist data fields: status (lost or found), pet type, gender, breeds, age of year, age of month, colour, chip number, location, contact phone number in a file pet.h. Define functions’ prototypes and other necessary definitions in the file pet.h.

The data fields’ types are decided by you.

Implement a function countRecords(char *) in a file pet.cpp that can return how many records of pets in a given text file. Implement a function loadRecords(char *, Pet *, int) load the pet records in a dynamic Pet array from the given text file. Implement a function printRecords(Pet *, int) print out all the pet records.

The example file pets.dat of pet records can be downloaded from the site of the lab task.

Each record stored in one line, different data fields separated by commas except the last field. There might be some empty lines in a given text file. The empty lines cannot be count as the records.

Implement driver program in the main function in pet.cpp to get the input text file name from a user, print out number of pet records that stored in the file, load pet records and print out all the data that loaded.

 

Don’t forget to delete the dynamic pet record array before the program finished.

 

Submission:

 

You should submit the files of task to the server by 11:59 PM on Friday, 11 March 2016 via command:

 

submit –u your-user-name –c CSCI204 –a L1 pet.h pet.cpp and input your password.

Make sure that you use the correct file names. The UNIX system is case sensitive. You must submit all files in one submit command line.

 

After submit your assignment successfully, please check your email of confirmation. You should keep this email for the reference.

 

You would receive ZERO of the marks if your program codes could not be compiled correctly.

 

Later submission will not be accepted. Submission via e-mail is NOT acceptable. End of Specification