0% found this document useful (0 votes)
28 views38 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's aims, challenges, proposed solutions, system requirements, design diagrams, and testing strategies. The project emphasizes creating a responsive and reliable system that logs elevator operations and supports future scalability.

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 PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views38 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's aims, challenges, proposed solutions, system requirements, design diagrams, and testing strategies. The project emphasizes creating a responsive and reliable system that logs elevator operations and supports future scalability.

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 PDF, TXT or read online on Scribd
You are on page 1/ 38

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


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

2
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
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.

3
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.N Description Week No Priority
1 Properly analyze the assignment brief to understand the Week 1 High
tasks that need to be completed.
2 Conduct a detailed requirement analysis and develop a Week 1 High
prototype to visualize the elevator's functionalities.
3 Design the graphical user interface, including floor Week 2 High
request buttons, control panel, display window, and log
button.
4 Implement button press handling and events to ensure Week 3 High
the elevator responds accurately to requests and
updates the display window.
5 Develop animations for elevator movement and door Week 4 Medium
operations, visualizing transitions between floors.
6 Set up an MS Access database to log elevator activities, Week 4 Medium
including time tracking of each action.
7 Implement functionality to log elevator actions with Week 5 High
timestamps and action details in the database.
8 Perform thorough testing to identify and resolve any Week 6 High
bugs or issues in the application.
9 Document all aspects of the project, including code Week 6 Medium
comments, user manual, and a detailed test report.
10 Conduct a comprehensive review of the project, making Week 7 High
necessary adjustments for the final draft submission.

4
System Requirement
Functional Requirements
Req. No Requirements Priority
1 A database management system, such as MS Access, for recording High
and logging elevator operations.
2 Microsoft Visual Studio 2019 or later with C# and Windows Forms High
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-oriented High
programming principles.
5 Understanding of GUI design, event handling in C#, and database Medium
integration.
6 Basics of concurrency and BackgroundWorker usage for multitasking. Medium
7 Ability to handle user inputs (button clicks, text input) and trigger High
elevator operations accordingly.
8 Support for saving and retrieving elevator logs, such as floor transitions Medium
and door activity.
9 Ability to manage multiple elevator systems within a single application. Low

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

Usability Requirements
Req. Requirements Priority
No
1 Windows operating system (Windows 10 or later) with .NET Framework. High
2 Familiarity with debugging and testing techniques to ensure reliability High
and performance.
3 The user interface should be intuitive, with clear labeling and easy-to- High
use controls for interacting with the elevator system.

5
4 System should provide real-time feedback to users on elevator activity High
(e.g., doors opening, moving up/down, etc.).
5 The design should ensure the system is accessible to users with Medium
disabilities (keyboard navigation, screen reader compatibility).
6 Provide a help section or user manual within the software for easy Low
reference.

System Design
Use Case Diagram

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.

6
Class Diagram

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.

7
Activity Diagram

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.

8
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 projects. In this elevator simulation, the database
records important details like the timestamps whenever the elevator moves, which floors

9
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

10
11
Implementation (Major code snippet)

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.

12
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.

13
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.

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

15
Testing
Test 1: Complete GUI for Task 1

Date of Test Purpose of Expected Result Actual Result Success/Error


Test
2024/11/08 Complete GUI The GUI should load The GUI loaded with Success
for Task 1 fully, displaying all all elements visible
elements correctly and functional, no
without errors. issues.

16
Test 2: Test the emergency stop functionality

Date of Test Purpose of Test Expected Actual Result Success/Error


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

17
Test 3: Verify the events are stored in the database

Date of Test Purpose of Expected Result Actual Result Success/Error


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

18
Test 4: Verify the history of logs are shown on the click of button

Date of Purpose of Expected Result Actual Result Success/Error


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

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

Date of Test Purpose of Test Expected Result Actual Result Success/Error


2024/11/10 Verify the logs Pressing the button The logs were Success
are cleared should clear all the cleared
when button is displayed logs from successfully, and no
pressed the screen and reset entries remained
the log history. displayed.

20
Test 6: Verify the data source is updated via DataAdapters

Date of Test Purpose of Expected Result Actual Result Success/Error


Test
2024/11/10 Verify the The data source The data source Success
data source should be updated was successfully
is updated via with the new data updated with the
DataAdapters through DataAdapters, new data, and
reflecting changes in changes were
the database. visible in the UI.

21
Test 7: Verify using relative path instead of absolute path

Date of Test Purpose of Test Expected Actual Result Success/Error


Result
2024/11/10 Verify using The application The application Success
relative path should successfully
instead of reference files used relative
absolute path using relative paths to access
paths, ensuring files, and it
portability worked across
across different different
environments. environments.

22
Test 8: Verify using BackgroundWorker

Date of Purpose of Test Expected Result Actual Result Success/Error


Test
2024/11/10 Verify using The The Success
BackgroundWorker BackgroundWorker BackgroundWorker
should perform tasks successfully ran the
in the background task in the
without freezing the background, and
main UI thread. the UI remained
responsive.

23
Test 9: Verify using State Pattern instead of if-else statements

Date of Purpose of Expected Result Actual Result Success/Error


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

24
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.

References
DevExpress. (n.d.). Creating a Basic Elevator Simulation. Retrieved from DevExpress Docs:
https://docs.devexpress.com/WindowsForms/DevExpress.XtraEditors.Elevator
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

25
Marking Matrix with Self-Assessment
Task Sub-tasks Possible Self- Reference to Mark
Number Marks assessment your testing Awarded
(completed report
Yes/No)
Task 1 Complete GUI for Task 1 10 Yes Test 1 10
Skeleton of event handlers 10 Yes Test 1 10
in place for all buttons
Task 2 All event handlers are 10 Yes Test 1/ Test 2 10
functional
Task 3 Database (DB) is designed 5 Yes Test 6 5
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 5
pressed, log 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 instead 5 Yes Test 7 5
of absolute path
Avoiding any duplication 5 Yes Test 6 5
among the event handlers
over the database related
functions
Task 4 Events described in Task 2 10 Yes Task 1/Task 2 10
animated using delegation
and timer
Task 5 Eliminating logical errors 5 Yes Task 6 5
and handling exceptions
with try and catch
Optimise the efficiency of 5 Yes Task 8 5
GUI by implementing
multiple tasks concurrently
via BackgroundWorker

26
Use state patterns instead 10 Yes Task 9 10
of if-else statements to
accommodate future
changes of the requirement
Task 6 Testing report 10 Yes Implemented 10
Total 100 100

Appendix

27
Form1.cs

28
29
30
31
32
Form1.Designer.cs

33
34
35
36
37

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy