Calendar - PowerPoint PPT Presentation

1 / 11
About This Presentation
Title:

Calendar

Description:

The general layout of the calendar. Aligning the columns of dates. ... How should we create the leading blanks? The dates must be aligned with the column headings. ... – PowerPoint PPT presentation

Number of Views:52
Avg rating:3.0/5.0
Slides: 12
Provided by: peopl93
Category:
Tags: blanks | calendar

less

Transcript and Presenter's Notes

Title: Calendar


1
Calendar
  • Project 5 Wed, Nov 20, 2002

2
Specific Problems
  • Deciding whether to print a single month or an
    entire year.
  • The general layout of the calendar.
  • Aligning the columns of dates.
  • Getting the full name of the month.
  • Centering the title of each month.
  • Starting the first of the month in the correct
    column.
  • Beginning a new week.

3
Deciding Whether to Print a Single Month or an
Entire Year
  • If the user enters only a year, then the first
    character is a digit.
  • If he enters a month and a year, then the first
    character is a letter.
  • Therefore, get the first character, using get().
  • Test it to see if it is a digit or a letter.
  • Then put it back into the input stream, using
    putback().

4
The General Layout of the Calendar
  • The first line should contain the month and year.
  • The next line should contain the weekdays
    (abbreviated).
  • Sun, Mon, , Sat.
  • With underscores.
  • The remaining lines contain the dates.

5
The General Layout of the Calendar
  • How wide should each column be?
  • Each column must contain the day name and
    separation from the neighboring columns.
  • Should there be blank lines for separation?

6
Aligning the Columns of Dates
  • If each column is 5 characters wide, exactly
    where should the date be placed within those 5
    characters?
  • One-digit dates must be properly aligned with
    two-digit dates.
  • How should we create the leading blanks?
  • The dates must be aligned with the column
    headings.

7
Getting the Full Name of the Month
  • The user enters the 3-letter abbreviation of the
    month name, e.g., "Nov".
  • We must replace this with the full name, e.g.,
    "November".
  • Create two arrays.
  • monthAbbr "Jan", , "Dec"
  • monthName "January", , "December"

8
Getting the Full Name of the Month
  • Search the first array for a match.
  • The full name of the month is in the same
    position of the second array.

9
Centering the Title on Each Month
  • First, get the full name of the month.
  • Use the size() string function to get the length
    of the month name.
  • The title of the month, e.g., "November 2002",
    is 5 characters longer than the month name,
    because of the year.
  • Subtract that width from the width of the
    calendar.
  • Indent half the remainder.

10
Starting the First of the Month in the Correct
Column
  • Create the first day of the month as a Date
    object.
  • Use the function GetWeekday() to find out which
    day of the week it is.
  • Search an array of weekdays for a match.
  • dayName "Sunday", , "Saturday"
  • Use this integer to indent the first row of dates.

11
Beginning a New Week
  • Let a variable represent the column number, 0
    through 6.
  • When the column number equals 6, start a new line
    after printing the date and reset the column
    number to 0.
  • Or, begin a new line after printing a date for
    "Saturday".
Write a Comment
User Comments (0)
About PowerShow.com