Programming Assignment 1, Advanced Programming I

Advanced Programming I, Spring 2006

Programming Assignment 1 - An Example Solution


Table of Contents

Rectangles

Rectangle Sets

Yard

Mpool

Input

Reading input takes place within a try-catch block to simplify error handling: if an input routine detects an error, it throws a string description of the error. Read a yard description from the given input stream; return the described yard. Throw a string error message if anything goes wrong. As described in the assignment, a yard description contains the yard dimensions followed by zero or more obstacle descriptions. Read a yard-dimension description from the given input stream; return the described yard. Throw a string error message if anything goes wrong. Read obstacle descriptions until eos from the given input stream and add the associated obstacles in the given yard. Throw a string error message if anything goes wrong. Parse the rectangle definition in the given string and return the associated rectangle; throw a string error message if anything goes wrong. Read into the given string reference the next non-blank string from the given input stream and return true. If something goes wrong, return false; the state of the referenced string is undefined. Return true iff the given string contains only blank characters.

Utilities

Some odds and ends useful to all code throughout the operating system.
<utils.h>=

#ifndef _utils_h_defined_
#define _utils_h_defined_

#include "rectangle-set.h"
#include "rectangle.h"

// Split the given rectangle according to the given rectangle set; return a set
// of the split rectangles.  The assumption is that r will be split into at
// least once.

   extern rectangle_set extended_rectangles(
     const rectangle &, const rectangle_set &);

// Return true iff the given rectangle is covered by one of the rectangles in
// the given rectangle set.

   extern bool covers_rectangle(const rectangle_set &, const rectangle &);

#endif

Index


This page last modified on 14 February 2006.