CSCI 689 Computer Assignment 6

$30.00

Download Details:

  • Name: Assignment-6-25gelv.zip
  • Type: zip
  • Size: 221.51 KB

Category:

Description

Rate this product

Write a C++ program to implement the class, which has the following data
members: and where represents the month
component of a object with valid values:
and Clearly, valid values for the
component depends on its component. For example, for the month of a
valid value for a day is between and but the month of the valid value is
between and ( if it’s a leap year). For the component, there is no maximum
value but it has the minimum value (not ).
Put the definition of your class in your header file and the implementations
of its member functions in your source file At the top of your header file source
file, insert the following statement:
The class should include the following member functions:
 This is a
constructor that can be used to create a object for the month
day and year where and are the
default values.

These member functions can be used to set the and
components of a object to the values and respectively, by a client
program.
 These
member functions can be used to return the and components
of a object, to a client program.
 This member function can be used to convert the
component of a object by changing its first letter to uppercase and the
rest of its letters to lowercase, so the month of a date can be entered as case
insensitive.
 This function checks a object, and if
it’s a valid date, it returns otherwise, it returns It calls the
member function to check if the component is
valid, and it calls the member function
to return the number of days in the month to check if the
component is valid. If the month is the function
calls the member function to get the correct
number of days in the month
The Date Class
2
 This member function can be used to convert the
component of a object in the form where is a
one- or two-digit date, the three-letter abbreviation for the month, and
is the four-digit year. For example, if the date is then this
function should return the string To help for the conversion, it
calls the non-member function: which takes
the integer value and returns its corresponding value as a string.
 This non-member function can
be implemented as a to the class, which overloads the extraction
operator ( ) for the class. It reads the individual date components from
the stream to the object where a date can be entered either in the
form or Since the character after the
component is optional, one way to deal with this issue is to use the
function for the stream . After extracting the component, you can read
one more character, and if that character happens to be a digit, then you can
put that character back into the stream
 This non-member
function can also be implemented as a to the class, which overloads
the insertion operator ( ) for the class. It gets the individual
components from the object and to the stream where is inserted in
in the form
Put the definitions of the components of the default date in your header file and
you can also include the following vector object for the months of a year:
so you can compare a given with
the elements of the vector to determine if the has a valid value.
A driver program is supplied to test your class. The source file of the driver program
is To use this source file, make a link from your program directory. To compile
the source files and and link their object files with the system library
routines, make a link to the and then execute: To test your program
with the data file execute: The files and the
are all located in the directory: The correct output file
is also located in the same directory.
The routine tests the member functions of the class for several given dates.
Some of these dates are generated by the class constructors and some of them are
entered from the For each object it calls the non-member function
This routine checks if is a valid date, and if it’s not, it prints
an error message on and it returns otherwise, it prints on and it
returns For a entered from the if the return value of is
it also prints on in the form The implementation of is
included in the driver program
3
When your program is ready, mail its source and header files of your class to your
TA by executing: