0% found this document useful (0 votes)
141 views3 pages

Department of Electrical Engineering: CS212 Object-Oriented Programming

The document outlines an assignment for an Object-Oriented Programming class. It includes 3 problems: 1) Modeling a virtual pet using procedural programming. 2) Creating a Tic-Tac-Toe game class with a 2D array board and methods for player turns. 3) Developing an elevator system class to model properties like only opening doors at floors and not moving between floors. It provides detailed requirements on the elevator system's behaviors, buttons, and time constraints.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
141 views3 pages

Department of Electrical Engineering: CS212 Object-Oriented Programming

The document outlines an assignment for an Object-Oriented Programming class. It includes 3 problems: 1) Modeling a virtual pet using procedural programming. 2) Creating a Tic-Tac-Toe game class with a 2D array board and methods for player turns. 3) Developing an elevator system class to model properties like only opening doors at floors and not moving between floors. It provides detailed requirements on the elevator system's behaviors, buttons, and time constraints.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Department of Electrical Engineering

Subject: CS212 Object-Oriented Programming Deadline: 23:59 PKT, Sunday 7 November, 2021

Class: BEE12B - Fall 2021

Assignment # 02 (30 Points) - Group Assignment

[CLO1] - Understand the difference between procedural and Object-Oriented Programming


paradigms

[CLO2] - Demonstrate the ability to carry out mapping of OOP constructs to real world scenarios.

• It is recommended to make this assignment in pairs.


• While working together, be very careful with public repositories.
• All solutions should be uploaded on LMS through the submission link (a single Zip file with
source codes together with all the dependencies and report in PDF format). Do not forget to
include your names and registration numbers in the report.
• Submit a printed copy during the class. Late submissions will not be accepted!
• Make sure that your findings can be reproduced.

Good Luck!

Problem 01:
(This is an extension of Assignment 01. You have to solve this problem using procedural language
i.e. without using the classes and highlight the difference between the OOP and procedural
language)
(5 marks) Write a C++ program that models a virtual pet. We will assume the pet will have
a weight and can be in a state of being hungry or not hungry. The pet can be fed which will
in turn effect the pet’s hunger state according to the following statements:
1. If the food weight is greater than or equal to one half of the pet’s weight, the pet
will not be hungry, otherwise it will be hungry.
2. The weight added to the pet will be one quarter of the food weight.
3. Write a driver’s program to test your class for member functions.
Instructions for Problem 02 & Problem 03
Separate the program interface from class implementation by using the scope resolution operator
and include the appropriate header file. You are encouraged to use good programming conventions
by entering appropriate comments, using indentations, and using descriptive variable names in
your programs.

Problem 02:
(10 marks) Create a class TicTacToe that will enable you to write a complete program to play
the game of tic-tac-toe.
• The class contains as private data a 3-by-3 two-dimensional array of integers.
• The constructor should initialize the empty board to all zeros.
• Allow two human players. Wherever the first player moves, place a 1 in the
specified square. Place a 2 wherever the second player moves. Each move must be
to an empty square. After each move, determine whether the game has been won or
is a draw.
Problem 03 (Elevator System Specification)
(15 marks) Make use of the Object-Oriented Programming constructs to develop a program in
C++ to monitor the behavior of an elevator system described below:
A basic elevator system is described below. For simplicity we assume that there is one door (rather
than two (one attached to the floor and one to the cab) which close on top of each other), no weight
sensors, no emergency bells, and no buttons except those to summon the lift to a particular floor,
and those for requesting a floor from inside the cab.

The elevator system has the following sensors:


- door is open/close
- elevator is stationary/moving
- elevator is at a particular floor
- elevator is in between floors

The elevator system has the following control signals:


- open/close door
- go up/down
- stop
The elevator system has the following buttons:
- elevator summoning (one at each floor)
- elevator floor request (one button per floor in each elevator)
Following the short description of the elevator system above, what follows gives a list of properties
which the elevator system has to satisfy during normal operation. These are classified as:

(Invariant properties that must be obeyed throughout the execution of your program)

In 1. Elevator never moves up/down when the door is not closed


In 2. Elevator never attempts to go above the topmost floor/below the lowermost floor
In 3. Elevator never moves unless a button press occurs which has not yet been serviced
In 4. Elevator never stops in between floors
In 5. Elevator doors are only opened once the elevator reaches a floor

Other Properties

Property 1. when a button (summon or floor request) is pressed, the elevator eventually services the
request.
Property 2. Multiple presses of the same button in between servicing are considered as a single request

Property 3. If an elevator is moving through a floor for which a summons button has been pressed, the
elevator should service that floor. Otherwise, the elevator closest to the requested floor should service
it.
Property 4. Door opening/closing signals always alternate each other; there should never be two
consecutive door opening / two consecutive door closing.
Property 5. If the summon button is pressed for a floor where the door is closing, the door
should open again

Time Properties

Time 1. Upon a request, after the door closes, the elevator starts moving in less than 3
seconds
Time 2. After the door has been open for 3 seconds, it closes automatically

Note: Make necessary adjustments according to your understandings.

You might also like