0% found this document useful (0 votes)
132 views12 pages

Creating Class Diagrams in Draw.io

This document provides an overview of object-oriented programming and assignments for week 1. It discusses creating class diagrams using draw.io and implementing classes, attributes, and methods in C++. The assignments section lists 4 programming challenges involving classes for Fraction, Triangle, Stack/Array, and Queue/LinkedList with various attribute and method requirements.

Uploaded by

Luyện Lê Văn
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)
132 views12 pages

Creating Class Diagrams in Draw.io

This document provides an overview of object-oriented programming and assignments for week 1. It discusses creating class diagrams using draw.io and implementing classes, attributes, and methods in C++. The assignments section lists 4 programming challenges involving classes for Fraction, Triangle, Stack/Array, and Queue/LinkedList with various attribute and method requirements.

Uploaded by

Luyện Lê Văn
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

Object Oriented Programming

Week 01
Object & Class

Cảm ơn thầy Trần Duy Quang đã cung cấp template cho môn học

Department of Software Engineering-FIT-VNU-HCMUS


OOP W01 – Object & Class

1
Notes
Create a single solution/folder to store your source code in a week.
Then, create a project/sub-folder to store your source code of each assignment.
The source code in an assignment should have at least 3 files:
• A header file (.h): struct definition, function prototypes/definition.
• A source file (.cpp): function implementation.
• Another source file (.cpp): named YourID_Ex01.cpp, main function. Replace 01 by id of an
assignment.
Make sure your source code was built correctly. Use many test cases to check your code before
submitting to Moodle.

2
OOP W01 – Object & Class

2
Content
In this lab, we will review the following topics:
• Class diagram
• Implement classes, attributes and methods in C++.

3
OOP W01 – Object & Class

3
Basic class diagram creation in [Link]
(Credit to Mr. Trần Duy Quang)
Using [Link] to create class diagram

- Step 01: Access [Link] choose to save your diagrams using Google Drive (recommended).

- Step 02: Choose Create new diagram to create a blank diagram.

4
OOP W01 – Object & Class

- Step 03: Create a Blank diagram, name it in the following format:

- Step 04: On the left panel, expand the UML node for all the shapes needed for creating class diagram

5
OOP W01 – Object & Class

- Step 05: Create your first class diagram by choosing class

This is the default result you will see:

6
OOP W01 – Object & Class

- Step 06: To create new attribute field, right click and choose Duplicate, then drag it into attribute
section (the middle one)

7
OOP W01 – Object & Class

- Step 6: Here is a class diagram

- Step 7: To submit your work. Firstly, drag and select your diagram. Secondly, choose menu File –
Export as – PNG. Thirdly, Zoom: 200%, Selection Only. Export. Finally, choose your local device and
download.

8
OOP W01 – Object & Class

9
OOP W01 – Object & Class

4 Assignments
A: YY: 01
H: YY: 04
Implement in C++, the following methods.

3.1. Fraction
Class: Fraction
Attribubtes:
1. Numerator
2. Denominator
Methods:
1. Input
2. Output
3. Add 2 fractions
4. Substract 2 fractions
5. Multiply 2 fractions
6. Divide 2 fractions. throw; if divided by zero
7. Reduce
8. Compare
9. IsPositive
10. IsNegative
11. IsZero

3.2. Triangle
Class Point.
Attributes:
1. x
2. y
Methods:
1. Input
2. Output
3. Distance from point A to point B
4. Distance to Ox
5. Distance to Oy

Class: Triangle

10
OOP W01 – Object & Class

Attributes:
1. Point A
2. Point B
3. Point C
Methods:
1. Input
2. Output
3. IsValidTriangle
4. Type of a triangle.
a. [Link]
5. Perimeter
6. Area
7. Center G

3.3. Stack / Array


Class: ArrayStack
Attributes:
1. int * data
2. int capacity: max number of elements in the stack
3. int top: index of top element or current number of elements in the stack
Methods:
1. init(int capacity)
2. push(x)
3. int x = pop()
4. peek(): return the top element but do not pop
5. isEmpty
6. isFull
7. clear

3.4. Queue / LinkedList


Class: LinkedListQueue
Attributes:
4. Node *head
5. Node *tail
6. int capacity: max number of elements in the queue
7. int num: current number of elements in the queue
Methods:
8. init(int capacity)

11
OOP W01 – Object & Class

9. enqueue(x) / push(x)
10. int x = dequeue()
11. peek(): return the top element but do not enqueue
12. isEmpty
13. isFull
14. clear

12

You might also like