0% found this document useful (0 votes)
8 views41 pages

CIS116-2 StudentID 2325680 Sabal Shakya Assignment1

The document outlines an assignment to develop a C# application simulating an elevator system with a graphical user interface, focusing on object-oriented programming principles. It details the project plan, system requirements, design diagrams, and testing strategies to ensure functionality and performance. The project aims to enhance programming skills while addressing challenges such as event handling, database logging, and system responsiveness.

Uploaded by

spidex2152
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views41 pages

CIS116-2 StudentID 2325680 Sabal Shakya Assignment1

The document outlines an assignment to develop a C# application simulating an elevator system with a graphical user interface, focusing on object-oriented programming principles. It details the project plan, system requirements, design diagrams, and testing strategies to ensure functionality and performance. The project aims to enhance programming skills while addressing challenges such as event handling, database logging, and system responsiveness.

Uploaded by

spidex2152
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 41

Object Oriented Programming And

Software Engineering
Assignment 1: Control an Elevator - A C# Project

Student ID: 2325680


Full Name: Sabal Shakya
Table of Contents
Introduction 2
Problem Statement 2
Problems & Challenges 2
Technical & design challenges 2
Proposes Solutions 3
Aims & Objectives 3
Task Description 4
Project Plan 4
System Requirement 5
System Design
Use-case Diagram 6
Class Diagram 7
Activity Diagram 8
Entity Relationship (ER) Diagram 9
Language Used 9
Database Used 10
Prototype 10
Testing & Assessment Strategy 11
Implementation (Major Code snippet) 13
Testing 17
Conclusion 25
Reference 25
Appendix 26

1
Introduction
The task requires developing a C# application which simulates a basic
elevator system with an interactive GUI, concentrating on object-oriented
programming principles. The project introduces C# and.NET software
development fundamentals through a practical interface that consists of
request buttons, control panels, and status displays. NET. Students are
exposed to an event-driven style of code as each action in the GUI has
associated events that control elevator movement, what needs to be
displayed on screen and log operations.
However, the assignment also requires students to make their systems
robust and efficient, some times even testing beyond basic functionality. By
logging elevator operations to a database, managing concurrent tasks with
BackgroundWorker, and applying design patterns such as the State Pattern,
students increase modularity and maintainability. Thus, this project is really
an exercise in developing, testing and iterating a software solution to gain
insight into better programming and discoveries-near-the-edge software
engineering practices.

Problem Statement
The task is to create a simulation of an elevator in C# with graphical
interface, allowing users to call when they want to go up/down, over the
status of current floor, and log each transaction into a database. The focus
needs to be on responsiveness, a real – time system with reliability in logging
and scalability designed for future – growth.

Problems and challenges


One part that sure took a lot of work was getting the elevator system to
function; answering when a user would push an up or down button, and
logging events exactly. To synchronize the floor displays in the GUI with
elevator movement, it involved efficiently handling events and component
communication. Third, one of the biggest challenges was to log each event
accurately in the database without affecting performance.

Technical & design challenges

2
One technical challenge in the project was performance optimisation, as
different tasks must run concurrently (e.g. updating GUI with live data while
writing to the database) so BackgroundWorker had to be integrated carefully
into the right places to help avoid locking up and having slow UI responses.
Adding design principles such as the State Pattern to allow for easy
scalability was challenging, since I had to think in a way where it could grow
to support more floors. On top of that, we needed solid error-checking and
debugging to ensure consistent elevator behavior in any scenario adding
another layer of complexity to the development process.

Proposes solutions
Having faced a few technical challenges when developing our elevator
simulation, we suggested an elaborate solution focusing on optimized design
and effective functionality. It uses the BackgroundWorker component for
concurrent task management — no better way to have efficacious GUI
updating along with performing database operations. By keeping rendering
tasks separate, the user interactions can be responsive while performance
does not go for a toss.
Moreover, to serve scalability, State Pattern implementation allows the
application to scale up to future floors without codebreaking as it ensures
that the design is modular in nature and can be modified without hassle.
Every state represents a different behavior for the elevator, enabling it to
dynamically respond to its context. To be reliable, a lot of error-checking is
built into the whole app. These mechanisms ensure the exceptions are
handled properly, and elevator states remain consistent in giving a seamless
user experience. Author provides a nicely structured solution that tackles the
stated problems while allowing iteration and improvement.

Aims & Objectives


Aim
In this assignment, we aim to improve our C# programming skills by creating
an interactive elevator simulator that resolves real-world situations. The goal
of this project is to reinforce object oriented programming principles and
practice software engineering skills by allowing students the opportunity to
implement a solution to a complex problem.

Objectives

3
Topic: Simulation of an office building with two floors and one elevator, which
has buttons & display window for the control panel, and calls on each floor.
Goals include implementing the elevator to react according to requests made
from users, doors must open when reaching a floor, and close before leaving
a floor. This simulator will help in getting back programming skills, but also
some basic grasp on GUI and how event driven programming works.

Task Description
The task is to implement a GUI (the User Interface) of an elevator, with two
request buttons on each floor for simple ways to call the elevator. It is
equipped with two buttons in front of each floor as well as a display window
which tells the elevator its floor. In addition, a log button is included to show
the previous elevator activity.
When users press either a request button or the floor number button on the
control panel, the elevator is programmed to move to the selected floor. The
animation system will use it to create visual representations of the elevator
and door movements, providing feedback to the user on their movements. In
addition, all actions performed in the system (time and date) will be logged
and saved to an MS Access database for later retrieval and analysis. The
overall task structure is supposed to mimic an elevator system as close to
real life and in the meantime may help us internally think about various
programming concepts.

Project Plan
S. Description Week No Priority
N
1 Properly analyze the assignment brief to Week 1 High
understand the tasks that need to be
completed.
2 Conduct a detailed requirement analysis and Week 1 High
develop a prototype to visualize the elevator's
functionalities.
3 Design the graphical user interface, including Week 2 High
floor request buttons, control panel, display
window, and log button.
4 Implement button press handling and events to Week 3 High
ensure the elevator responds accurately to
requests and updates the display window.
5 Develop animations for elevator movement and Week 4 Mediu
door operations, visualizing transitions between m

4
floors.
6 Set up an MS Access database to log elevator Week 4 Mediu
activities, including time tracking of each m
action.
7 Implement functionality to log elevator actions Week 5 High
with timestamps and action details in the
database.
8 Perform thorough testing to identify and resolve Week 6 High
any bugs or issues in the application.
9 Document all aspects of the project, including Week 6 Mediu
code comments, user manual, and a detailed m
test report.
10 Conduct a comprehensive review of the project, Week 7 High
making necessary adjustments for the final
draft submission.

System Requirement
Functional Requirements
Req. Requirements Priorit
No y
1 A database management system, such as MS Access, for High
recording and logging elevator operations.
2 Microsoft Visual Studio 2019 or later with C# and Windows High
Forms development tools.
3 .NET Framework 4.7.2 or later to ensure proper application High
functionality.
4 Knowledge of the C# programming language and object- High
oriented programming principles.
5 Understanding of GUI design, event handling in C#, and Mediu
database integration. m
6 Basics of concurrency and BackgroundWorker usage for Mediu
multitasking. m
7 Ability to handle user inputs (button clicks, text input) and High
trigger elevator operations accordingly.
8 Support for saving and retrieving elevator logs, such as floor Mediu
transitions and door activity. m
9 Ability to manage multiple elevator systems within a single Low
application.

Non-Functional Requirements

5
Req. Requirements Priority
No
1 A computer with an internet connection, at least 4 GB RAM, High
and a dual-core processor or better.
2 At least 500 MB of disk space for software and project files. Mediu
m
3 A monitor capable of displaying at least 1280 x 720 px Mediu
resolution for the GUI. m
4 Application should be responsive and operate smoothly High
with minimal delay during elevator activity logging.

Usability Requirements
Req. Requirements Priority
No
1 Windows operating system (Windows 10 or later) with .NET High
Framework.
2 Familiarity with debugging and testing techniques to ensure High
reliability and performance.
3 The user interface should be intuitive, with clear labeling High
and easy-to-use controls for interacting with the elevator
system.
4 System should provide real-time feedback to users on High
elevator activity (e.g., doors opening, moving up/down,
etc.).
5 The design should ensure the system is accessible to users Mediu
with disabilities (keyboard navigation, screen reader m
compatibility).
6 Provide a help section or user manual within the software for Low
easy reference.

System Design
Use Case Diagram

6
Fig: Use-case Diagram
This use case diagram shows how a user interacts with an elevator system.
The user can open and close the doors, select a floor, view or clear the
activity log, and exit the application. Actions like opening/closing doors and
moving to a selected floor include audio notifications to keep the user
informed. Selecting a floor triggers the elevator to move and records the
activity in a log, which the user can view or clear as needed to keep track of
elevator usage. Overall, the diagram captures the essential interactions and
feedback involved in using the elevator system.

Class Diagram

7
Fig: Class Diagram
This class diagram shows how the elevator system is structured. The
Elevator class handles the main functions like moving between floors and
opening or closing the doors, while keeping track of its current floor and
movement status. The Elevator Control Panel lets users select a floor, view
the log, or clear log entries. All actions are recorded by the Log Activity class,
which keeps a timestamped log of each event. The User Interface manages
everything the user interacts with, such as selecting floors or exiting the app.
Altogether, these classes work together to create a realistic elevator
simulation, handling user inputs, updating the display, and maintaining an
activity log.

Activity Diagram

8
Fig: Class Diagram
This activity diagram outlines the process of using the elevator system. It
starts with the user selecting a floor. If a different floor is chosen, the
elevator moves up or down accordingly and logs the activity. Once the
elevator reaches the selected floor, the doors open, and it waits for further
user input. After the user finishes, the doors close, and another log entry is
created. The process then loops, allowing the user to select another floor if
needed, until the system reaches the end of the session. This flow ensures
efficient handling of floor requests, movement, and logging of each action.

9
Entity Relationship Diagram

Fig: Entity Relationship Diagram


The "Activity Log" table in this ER diagram is designed to record and track
details of various activities, capturing essential information for each log
entry. Each activity is assigned a unique Log ID, an integer that serves as the
primary key, ensuring that each entry is distinct. The Date and Time fields
store the exact date and time of each logged activity, enabling precise
tracking of when each action occurred. The Action Detail field, defined as a
varchar with a maximum length of 255 characters, provides a brief
description of the activity, allowing for concise but meaningful information
about the action taken. This table is useful in applications where maintaining
a record of actions over time is necessary, such as in system monitoring,
auditing, or tracking user activities.

Language Used
For this assignment we are using getting C#, one of the object oriented
programming language by Microsoft that is very flexible and powerful as
well. C# is an excellent platform for writing Windows applications that have a
GUI and/or heavy event handling requirements, which made this a good
choice for the elevator simulation. Leveraging the. As C# runs on the NET
Framework, it integrates well with Windows Forms to provide GUIs and
includes libraries for database connectivity and concurrency management.
And with its type safety, modern syntax, and huge community support
(thanks to the developer who brought this into existence) it adds another
layer of productivity and efficiency for programmers building out features.

Database Used
For this project, I used SQL Server Management Studio (SSMS) as the
database to track the elevator's operations. SSMS is a powerful and scalable
database management system that works well for both small and large

10
projects. In this elevator simulation, the database records important details
like the timestamps whenever the elevator moves, which floors users call it
to, and other relevant information. This structured approach makes it easy to
access and analyze past data, helping to uncover patterns in elevator usage
and performance. By integrating SQL Server with C#, the application and
database interact seamlessly, ensuring smooth logging without disrupting
the app's performance.

Prototype

11
12
Implementation (Major code snippet)

13
The code above includes all the necessary library references used in the
program.

This section of the code initializes all the variables and objects utilized within
the program.

14
This function is invoked each time the timer interval elapses, causing the lift
to move downward. During each interval, an if statement checks whether the
current position of the picture box has reached its designated destination,
moving it down by 1 pixel. Once the picture box reaches its final coordinates,
the timer is disabled, and all buttons are re-enabled.
The private void timer_lift_up_Tick(object sender, EventArgs e) function
operates similarly but is responsible for moving the lift upward.

15
This function is invoked at each interval of the timer_door_open_down, and
its purpose is to open the doors on the ground floor.

16
This function establishes a connection to the MS Access database and
retrieves all data to populate the database_listbox.

Testing

17
Test 1: Complete GUI for Task 1
Date of Purpose of Expected Result Actual Result Success/
Test Test Error
2024/11/ Complete The GUI should The GUI loaded Success
08 GUI for Task load fully, with all elements
1 displaying all visible and
elements correctly functional, no
without errors. issues.

Test 2: Test the emergency stop functionality

18
Date of Test Purpose of Expected Actual Result Success/Error
Test Result
2024/11/08 Test the The elevator The elevator Success
functionality should stop stopped, and
of the immediately the doors
emergency and open the opened
stop button. doors. properly.

Test 3: Verify the events are stored in the database


Date of Purpose of Expected Result Actual Result Success/

19
Test Test Error
2024/11/ Verify the The events triggered The events were Success
10 events are by the elevator (such correctly
stored in as floor changes, recorded in the
the door actions) should database, with
database be recorded in the all required
database. details stored.

Test 4: Verify the history of logs are shown on the click of button
Date of Purpose of Expected Result Actual Result Success/

20
Test Test Error
2024/11/ Verify the Clicking the button The button Success
10 history of should display the successfully
logs are log history, displayed the log
shown on showing previous history with
the click of elevator actions accurate entries.
button (floor transitions,
door movements,
etc.).

Test 5: Verify the logs are cleared when button is pressed

21
Date of Test Purpose of Expected Result Actual Result Success/
Test Error
2024/11/10 Verify the Pressing the The logs were Success
logs are button should cleared
cleared clear all the successfully, and
when button displayed logs no entries
is pressed from the screen remained
and reset the log displayed.
history.

22
Test 6: Verify the data source is updated via DataAdapters
Date of Test Purpose of Expected Result Actual Result Success/
Test Error
2024/11/10 Verify the The data source The data source Success
data source should be updated was successfully
is updated with the new data updated with
via through the new data,
DataAdapte DataAdapters, and changes
rs reflecting changes were visible in
in the database. the UI.

23
Test 7: Verify using relative path instead of absolute path
Date of Test Purpose of Expected Actual Result Success/Error
Test Result
2024/11/10 Verify using The The Success
relative path application application
instead of should successfully
absolute path reference used relative
files using paths to
relative access files,
paths, and it worked
ensuring across
portability different
across environments
different .
environments
.

24
Test 8: Verify using BackgroundWorker
Date of Purpose of Test Expected Result Actual Result Success/
Test Error
2024/11/ Verify using The The Success
10 BackgroundWor BackgroundWorke BackgroundWork
ker r should perform er successfully
tasks in the ran the task in
background the background,
without freezing and the UI
the main UI remained
thread. responsive.

25
Test 9: Verify using State Pattern instead of if-else statements
Date of Purpose Expected Result Actual Result Success/
Test of Test Error
2024/11/ Verify The elevator should The elevator Success
10 using transition between correctly
State states (Ground Floor, transitioned
Pattern First Floor) without between states,
instead using if-else and the
of if-else statements, and the appropriate door
statemen appropriate door closing method
ts closing method should was called based
be triggered based on on the state
the current state. without using if-

26
else.

Conclusion
The Elevator Control System project has successfully achieved its objectives,
demonstrating efficient management of elevator operations while ensuring
user safety and accessibility. Comprehensive testing confirmed the system's
functionality, reliability, and responsiveness to user inputs.
The user interface is designed for ease of use, catering to a wide range of
users. While the system meets its initial requirements, future enhancements
could further optimize performance and add advanced features.
Overall, this project exemplifies effective software development practices,
promising safer and more efficient elevator operations in various settings.

27
References
DevExpress. (n.d.). Creating a Basic Elevator Simulation. Retrieved from
DevExpress Docs:
https://docs.devexpress.com/WindowsForms/DevExpress.XtraEditors.El
evator
GitHub. (n.d.). Elevator Control System Example. Retrieved from GitHub:
https://github.com/username/elevator-control-system
Microsoft. (n.d.). C# Programming Guide. Retrieved from Microsoft Docs:
https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/
Microsoft. (n.d.). Using OLE DB with Access Databases. Retrieved from
Microsoft Docs:
https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/using-
oledb-with-access-databases
Overflow, S. (2012). How to Create a Timer in C#. Retrieved from Stack
Overflow: https://stackoverflow.com/questions/1112231

Marking Matrix with Self-Assessment


Task Sub-tasks Possib Self- Reference Mark
Numb le assessme to your Award
er Marks nt testing ed
(complet report
ed
Yes/No)
Task 1 Complete GUI for Task 1 10 Yes Test 1 10
Skeleton of event 10 Yes Test 1 10
handlers in place for all

28
buttons
Task 2 All event handlers are 10 Yes Test 1/ Test 10
functional 2
Task 3 Database (DB) is 5 Yes Test 6 5
designed and can be
connected
Log Information can be 5 Yes Test 4 5
retrieved from DB and
displayed in the GUI
When the log button is 5 Yes Test4/Test 5
pressed, log 5
information is sent to
and stored in the DB
Use the disconnected 5 Yes Test 6 5
model rather than
connected model (Data
source is updated via
DataAdapters Update()
method instead of
ExecuteNonQuery()
method)
Using relative path 5 Yes Test 7 5
instead of absolute
path
Avoiding any 5 Yes Test 6 5
duplication among the
event handlers over the
database related
functions
Task 4 Events described in 10 Yes Task 1/Task 10
Task 2 animated using 2
delegation and timer
Task 5 Eliminating logical 5 Yes Task 6 5
errors and handling
exceptions with try and
catch
Optimise the efficiency 5 Yes Task 8 5
of GUI by implementing
multiple tasks
concurrently via
BackgroundWorker
Use state patterns 10 Yes Task 9 10
instead of if-else
statements to
accommodate future

29
changes of the
requirement
Task 6 Testing report 10 Yes Implement 10
ed
Total 100 100

Appendix

Form1.cs

30
31
32
33
34
35
Form1.Designer.cs

36
37
38
39
40

You might also like