Assignment 7

Object Oriented Programming

  1. Develop an abstract data-type called interval. An interval is defined by two real numbers signifying the lower and upper bounds. Develop the following functions for carrying out operations on intervals:

    • make_nterval, for creating an interval
    • intadd, for adding two intervals. Here the minimum value of the sum should be the sum of the two lower bounds and the maximum value of the sum should be the sum of the two upper bounds.
    • intsubtract, for subtracting two intervals.
    • intmult, for multiplying two intervals.
    • intdiv, for dividing two intervals.
  2. Stack is a last-in-first-out kind of a data structure which is used in the real world where order of evaluation of data items is necessary - for instance, evaluating expressions with operands and operators (associated with precedence), tasks involving backtracking (eg: depth first search), etc. Implement an integer stack which uses python lists to store the contents. In particular, implement the following methods of stack: pop, push, peek, isEmpty, isFull.

Challenge (optional)

Implement the Tetris game using OOP in python. In Tetris, any object has three states: rotation (by 90 degrees), shape and color. In terms of the behavioural attributes a Tetris object can either: fall, move sideways, or rotate.

Next