All of the work in this project is my own! I have not left copies of my code in public folders on university computers. I have not given any of this project to others. I will not give any portion of this project to others taking this class. I realize that the penalty for turning in work that is not my own can range from an "F" in the class to dismissal from Trinity University.
Print Name __________________________ Time Required = ______.____ Hrs.
Signature __________________________
Print Name __________________________
Print Name __________________________
Print Name __________________________
Print Name __________________________
Athlete Timing I -
Read/Write
Individual/Team (1-3 Persons) Assignment
35 Points
Make Any Changes Necessary For Compilation
Use one of the computers in our class room to do this project.
1] This computer has ________________________ Bytes of RAM
2] The hard drive is ___________________________ GB
3] The hard drive speed is ______________________RPM
[5600/7200]4] The processor speed is ______________________GHz
5] The windows operating system is ______________________
6] The windows operating system is a____________________ {32/64} bit OS.
7] _____________ {T/F} A 300 GB drive that is severely fragmented will perform more poorly than one that has been optimized/defragmented.
8] _____________ {T/F} A 7200 RPM drive has will generally perform faster than a 5600 RPM drive.
1] Begin with a basic project file. Add your updated utilities.hpp and utilities.cpp. Add your Athlete.hpp and Athlete.cpp
2] Rename the project folder to Athlete-Timing-1-Tom-Maurice <== replace Tom-Maurice with the first names of each team member.
1] In the Test function/function, write a block of code to display 100 random numbers, in the range 1-10, ten to a line. Use function RandNo. Put the following in your utilities files; modify them to make them work if necessary.
/////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
// RandNo //
// //
// Purpose : Explicitly return a random integer value in the range //
// Low <= X <= High //
// //
// Written By : Dr. Thomas E. Hicks Environment : Windows XP //
// Date : XX/XX/XX Compiler : Visual C++ //
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
long int RandNo(long int Low, long int High)
{
double
Factor;
Factor = (float) rand()/(RAND_MAX + .0000001);
return (int((High - Low + 1) * Factor)+ Low);
}
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
// SetRandomSeed //
// //
// Purpose : Set the seed of the random number generator so that the clock is //
// used to change the values. Not real good, but better than nothing. //
// //
// Written By : Dr. Thomas E. Hicks Environment : Windows XP //
// Date : XX/XX/XX Compiler : Visual C++ //
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
void SetRandomSeed(void)
{
srand((unsigned) time(NULL) ); // Not real good, but better than nothing!
}
2] In the Test function/function, write a block of code to display 100 random numbers, in the range -10 to +10, ten to a line. Use function RandNo.
_______ {T/F} Function RandNo appears to work
_______ {T/F} Unless you change the see on the random number generator, you get the same collections of numbers each time you run the program.
3] Place a call to function SetRandomSeed(void) at the top of your Test function. Run the program again.
_______ {Y/N} Do you get the same collections of numbers each time you run the program now?
4] A good place for you to place the two random number functions is in the Utilities files. Move them now.
Some of these factors can be analyzed theoretically before any programming begins and some can not.
No one data structure is best for everything. Just as a fly swatter is more appropriate to kill a fly in your kitchen than napalm or a scud missile, some data structure algorithms are more cost effective to implement and maintain than others. In order to make adequate decisions on what algorithms to use, it is often necessary to create a test file to time reads and writes.
1) Create Test function.
1) Do the following in the Test function.
Create a file pointer, called afp.
The
line of code to create the file pointer is :__________________________________________________________________________________________
Write the code to Create/Open a direct access file in wb+ mode - Create New + Read & Write. Call the file
The line of code to
create the file is :__________________________________________________________________________________________
_______ {Y/N} When you open a file in the wb+ mode, any information previously exiting in the file is destroyed and a brand new clean/empty file is created.
Write the code to create three Athletes objects called Athlete1, Athlete2, and Athlete3; put in your name(s); add friends names if necessary.
Athlete Athlete1(???), Athlete2(???), Athlete3(???);
Write the code to move the read/write pointer to record 0 of your file and place the contents Athlete3 into that record. Do not use our WriteRecord function.
The line of code to
move the read/write pointer to record 0 is :__________________________________________________________________________________________
The line of code to write
the Athlete3 info is in record referenced by the read/write pointer is :__________________________________________________________________________________________
Write the code to move the read/write pointer to record 1 of your file and place the contents Athlete2 into that record. Do not use our WriteRecord function.
The line of code to
move the read/write pointer to record 1 is :__________________________________________________________________________________________
The line of code to write
the Athlete2 info is in record referenced by the read/write pointer is :__________________________________________________________________________________________
Write the code to move the read/write pointer to record 2 of your file and place the contents Athlete1 into that record.. Do not use our WriteRecord function.
The line of code to
move the read/write pointer to record 2 is :__________________________________________________________________________________________
The line of code to write
the Athlete1 info is in record referenced by the read/write pointer is :__________________________________________________________________________________________
Write the code to close the file.
The line of code to
close the file is:__________________________________________________________________________________________
2] Write the code to Open a direct access file Athlete1.fil in rb+ mode - Read & Write.
The line of code to
open this existing file to read or write is__________________________________________________________________________________________
_______ {Y/N} When you open a file in the rb+ mode, any information previously exiting in the file is destroyed and a brand new clean/empty file is created.
Write the code to create two more Athletes objects called Athlete0, Athlete4 and Athlete5.
Athlete Athlete0(???), Athlete1(???), Athlete5(???);
The line of code to
move the read/write pointer to record 2 is :__________________________________________________________________________________________
The line of code to
fill Athlete4 with what-ever info is in record referenced by the read/write pointer is :__________________________________________________________________________________________
The line of code to
display Athlete4 is :__________________________________________________________________________________________
The line of code to
move the read/write pointer to record 0 is :_________________________________________________________________________________________
The line of code to
fill Athlete5 with what-ever info is in record referenced by the read/write pointer is :__________________________________________________________________________________________
The line of code to
display Athlete5 is :__________________________________________________________________________________________
Do Athlete1.Get() and fill the object with one of your favorite Athletes.
The line of code to
move the read/write pointer to record 3 is :__________________________________________________________________________________________
The line of code to write
the Athlete1 info is in record referenced by the read/write pointer is :__________________________________________________________________________________________
The line of code to
move the read/write pointer to record 1 is :__________________________________________________________________________________________
The line of code to
fill Athlete1 with what-ever info is in record referenced by the read/write pointer is :__________________________________________________________________________________________
_________ {Y/N} I/We were successful appending the new record 3 to the file.
_________ {Y/N} I/We were successful replacing record 1 to the file.
Using windows, determine the exact number of bytes in file Athlete1.fil.
sizeof(Athlete) = ____________________________________________________________ bytes
The number of records in file Athlete1 = _________________________________________ records
The number of bytes in file Athlete1 = ___________________________________________ bytes
D
oes this make sense? Explain!
_______________________________________________________________________________
_______________________________________________________________________________
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
// //
// WriteRecord //
// //
// Purpose : Write the direct access record RecordNo from file *fp from //
// container Info. No error checking yet! //
// //
// Written By : Dr. Thomas E. Hicks Environment : XP //
// Date : XX/XX/XX Compiler : Visual C++ //
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
template <class InfoType>
bool WriteRecord(InfoType *Info, long int RecordNo, FILE *fp)
{
// You Do
return (SUCCESSFUL);
}
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
// //
// ReadRecord //
// //
// Purpose : Read the direct access record RecordNo from file *fp into //
// container Info. No error checking yet! //
// //
// Written By : Dr. Thomas E. Hicks Environment : Windows 2000 //
// Date : XX/XX/XX Compiler : Visual C++ //
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
template <class InfoType>
bool ReadRecord(InfoType *Info, long int RecordNo, FILE *fp)
{
// You Do
return (SUCCESSFUL);
}
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
// FileLength //
// //
// Purpose : Explicitly return the number of direct access file records in the //
// open file referenced by FilePtr. //
// //
// Written By : Dr. Thomas E. Hicks Environment : Windows 2000 //
// Date : XX/XX/XX Compiler : Visual C++ //
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
long int FileLength (FILE *FilePtr, long int NoBytesPerRecord)
{
long int
Bytes;
// You Do
return (1);
}
1
] Use the slides to complete functions ReadRecord, WriteRecord, and FileLength in the Utilities.hpp and Utilities.cpp. Make sure that your Athlete class items are 10,000 bytes each (add char Satellite[???] to the private data to extend the record). Test them.2) Do the following in the Test function.
Write the code to Open create direct access file, file Athlete2.fil, in wb+ mode - Read & Write.
Using WriteRecord, write the contents of Athlete0 to record 0 on the file. Do not use fwrite or fseek.
The line of code to
move write the contents of Athlete0 to record 0 was :__________________________________________________________________________________________
Using WriteRecord, write the contents of Athlete1 to record 1 on the file. Do not use fwrite or fseek.
Using WriteRecord, write the contents of Athlete2 to record 2 on the file. Do not use fwrite or fseek.
Using WriteRecord, write the contents of Athlete3 to record 3 on the file. Do not use fwrite or fseek.
Write the code to close the file.
3) Do the following in the Test function.
Write the code to Open an existing direct access file, file Athlete2.fil, in rb+ mode - Read & Write.
Using ReadRecord, write the record 3 into Athlete4. Do not use fread or fseek. Do Athlete4.Display( ).
The line of code to
fill Athlete4 with the contents of record 3 was :__________________________________________________________________________________________
Using ReadRecord, write the record 2 into Athlete4. Do not use fread or fseek.Do Athlete4.Display( ).
Using ReadRecord, write the record 1 into Athlete4. Do not use fread or fseek.Do Athlete4.Display( ).
Using ReadRecord, write the record 0 into Athlete4. Do not use fread or fseek.Do Athlete4.Display( ).
4) Do the following in the Test function.
Write the code to use FileLength to display "The number of records in file Athlete2.fil = 4"
The line of code to
display The number of records in file Athlete2.fil = 4 was :
__________________________________________________________________________________________
_________ {T/F} With the exception that ReadRecord does Not trap errors properly, ReadRecord works correctly.
_________ {T/F} With the exception that WriteRecord does Not trap errors properly, WriteRecord works correctly.
_________ {T/F} With the exception that FileLength does Not trap errors properly, FileLength works correctly.
1] RandomAthlete shall use the Set method in your Athlete class to change the private data.
char
Name [40];
long int
No,
SportNo;
double
EquipmentValue;
The No field of the record with a random number in the range 1-RandMax.
Fill the Name with 15 random letters in the range A, B, C, ..., Z.
Fill the SportNo with a random value in the range 1-20
Fill the EquipmentValue with a random value in the range 1.00 - 99.99
Fill the Satellite with a blank string "".
1] Create a new file with the appropriate file name.
2] Write a blank Athlete to record one of the file.
3] Fill the rest of the records with RandomAthletes. If the NoAthletes = 10, then records 1-10 shall contain RandomAthletes.
4] Close the file.
1] Add the templated DisplayFile function to your utilities class. It shall use display the file in the following format (Record Numbers decending on the left);
Message (if any)
----------------------------------------------------
4 |
50 characters of record 4 info |
----------------------------------------------------
3 |
50 characters of record 3 info |
----------------------------------------------------
2 |
50 characters of record 2 info |
----------------------------------------------------
1 |
50 characters of record 1 info |
----------------------------------------------------
0 | Just a Blank Record for now - not data
record |
----------------------------------------------------
File : RanAthletes-10.fil
NoRecords = 10
1] Place the following in main. Comment out the call to function Test( )!
CreateRandomAthleteNodeFile("RanAthletes-10.fil", 10);
CreateRandomAthleteNodeFile("RanAthletes-1000.fil", 1000);
// CreateRandomAthleteNodeFile("RanAthletes-10000.fil", 10000);
// CreateRandomAthleteNodeFile("RanAthletes-100000.fil", 100000);
DisplayFile("RanAthletes-10.fil", Athlete1, "\n\nAthletes 1-10\n");
2] Backup this project on your Y drive. Back up this project on a thumb drive or your personal computer. Put a copy in each team members "To Be Graded Folder" on Ananke.
3] Those Labs labeled "Individual Assignment" are to be done separately by each individual. Using a pen, each individual is to print his/her Title at the top of this document in the space provided and sign it. Those Labs labeled "Team Assignment" may be done as a team or individually. Using a pen, each individual on the team is to print print his/her Title at the top of this document in the space provided and sign it.
A] A fully completed assignment sheet. Using an ink pen, print your Name and sign this lab at the top. Record the amount of time you spent working on the lab.
B] Never place your only copy of your project just on Ananke. Never leave a copy of your project on a public server. Always maintain a copy your project to your Y drive. Always maintain a copy your project on your personal computer.
C
] Nothing will be graded until this lab form is submitted. Staple the pages. Fold the lab Horizontally (like a hot dog) and write your name nice and large on the outside. Place it on the professor desk before the beginning of lecture on the day it is due. All assignments are due the next class period unless otherwise designated on the schedule page.