CMSC 162 -- Lab 1

Lab 1

Getting Started

Log onto a computer science server making sure to change the port number.

Linux Commands

There is a handy linux program called wget which takes a url (web address) and will download the file at that address. Another useful program called tar combines and compresses (or decompresses) files.
  • wget address downloads the file at the address and saves it to the current directory
  • tar -xvzf filename will extract a compressed tar file (called a tarball)

Follow these instructions to get your files ready to start lab.
  • Use wget to download the file at http://cs.longwood.edu/courses/cmsc162/f18/files/lab1.tgz
  • Uncompress the lab1.tgz file by using tar -xvzf lab1.tgz
  • Use ls to see that there is a new directory called lab1
  • Use cd lab1 to change directory to the lab1 directory


Documentation

Documenting your work is an important habit to develop. It is customary (and required in this class) to include a README.txt file with any program you write. Your README.txt file should include your name, the date, the project (or lab), a description of the project, instructions on how to compile, instructions on how to run, and any test cases.

An Example:
Lab1: Time
Author: Julian Dymacek
Date: 2018 Aug. 21

Review and working with structs.

To compile:
	make

To run:
	./lab1

To test:
	type in cases
		


The Problem

You will be writing struct to store the information about a date. You will write some functions dealing with dates.
  1. write test cases
  2. write a README
  3. practice using data types


Implementation

  1. Date
    a struct to store a date 
  2. before
    input: Date a and Date b
    output: boolean value, true if a is before b
  3. after
    input: Date a and Date b
    output: boolean value, true if a is after b
  4. nextDay
    input: Date a
    output: a moved forward by one day
  5. forward
    input: Date a and an integer i
    output: a moved forward by i days
  6. isLeapDay
    input: Date a
    output: boolean value, true if a is a leap day
  7. between
    input: Date a Date b
    output: an integer giving the number of days between the two dates
    	if b is before a the value should be negative
    
  8. asString
    input: Date a
    output: a string version of the Date day/month/year

Testing

Test your program using your test cases. If you don't get the correct (expected) answers try to understand what went wrong. Make small changes (hopefully fixes!), recompile and try your test case again. If you are absolutely stuck see me or the tutor.

Handin

When you are done you need to hand in your lab. The easiest way is to type make handin.

If you have changed file names or directory names you will need to change to the directory which contains the directory you wish to hand in. We will use the handin cmsc162 assignment directory command. In this case you will type: handin cmsc162 lab1 lab1

You lab is due at 11:59pm Aug. 28th 2018.