1. Trang chủ
  2. » Luận Văn - Báo Cáo

Information technology assignment 2 unit programming

59 0 0
Tài liệu được quét OCR, nội dung có thể không chính xác
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Tiêu đề Information Technology Assignment 2 Unit: Programming
Tác giả Le Tran Quoc Bao
Người hướng dẫn Nguyen Hoang Anh Vu
Trường học BTEC FPT International College
Chuyên ngành Information Technology
Thể loại Bài tập
Năm xuất bản 2022
Thành phố Da Nang
Định dạng
Số trang 59
Dung lượng 14,02 MB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

CHAPTER 2 PROBLEMS RELATED TO PROGRAMMING METHODS ANDIDEL J LO2 Explain the characteristics of procedural, object-oriented and event driven programming, conduct an analysis of a suitable

Trang 2

‘BTEC ‘

ASSIGNMENT 2 FRONT SHEET

Student name LE TRAN QUOC BAO] Student ID BD00033

Class Assessor name NGUYEN HOANG ANH VỤ

TT05102

Student declaration

I certify that the assignment submission is entirely my own work and I fully understand the con-

sequences of plagiarism I understand that making a false declaration is a form of malpractice

Trang 4

ACKNOWLEDGMENTS First of all, I would like to express a special and enormous thanks to my family for their invaluable encouragement, enthusiasm, and support Without all of this, I couldn't have

achieved it Second, I would like to sincerely thank teacher NGUYEN HOANG ANH VU for

enthusiastically supporting me to achieve my academic results and thanking him for his support in the exercises as well as the knowledge that he taught and taught solve whole- heartedly Besides, I would also like to thank my friends at BTEC FPT International College for allowing me to exchange knowledge and help me understand the issues in this course

Finally, I would also like to thank the authors, brothers, sisters and friends who have pro-

vided a lot of knowledge to use as references throughout this exercise

Trang 5

ASSURANCE

I certify that this assignment is my work, based on my study and that I have acknowledged

all material and sources used in its preparation, whether they be books, articles, reports,

lecture notes, and any other kind of document, electronic or personal communication I

also certify that this assignment has not previously been submitted for assessment in any other unit, except where specific permission has been granted from all unit coordinators involved, or at any other time in this unit, and that I have not copied in part or whole or otherwise stealing ideas the work of other persons

Learners declaration

I certify that the work submitted for this assignment is my own and research

sources are fully acknowledged

Student signature: Date:

LE TRAN QUOC BAO

Trang 6

CHAPTER 2 PROBLEMS RELATED TO PROGRAMMING METHODS ANDIDEL J

LO2 Explain the characteristics of procedural, object-oriented and event driven

programming, conduct an analysis of a suitable Integrated Development Environment

2.1.1 Procedure-Oriented Programmine(POP) 1

2.1.2 Event-driven programming 2

2.1.3 Object-oriented programming (OOP) 5

2.1.4 Characteristics of the proeramming modeÌs c2 21121211111 1011211182 6

programming (OOP) 9

2.2 Analyze the common features that a developer has access to inan IDE(M2) 10

P2 ¡Mi ii 0n 3 10

2.2.2 Basic features of common IDE 10

2.2.3 Benefits of IDE for programmers 13

CHAPTER 3 IDE problems, debugging proeedures, and codine standards 14 LO3 Implementbasicalgorithms in code using an IDE 14

Trang 8

LIST OF TABLES AND FIGURES Table 2-1 Compare PÓOP and ÔPP L1 1 H10 11111 1111111111011 1111111 HH t1 0g 9 Table 3-1: Some coding standard ác S1 1911101011201 11 111111 1 HH1 11 nấu 36

Figure 2-1 Example for Proeedural prosramm1ng - - ¿ : c1 19111 6111111111111 11 re 2

In90199)9 588 e- 4 I0 c8 ) 8n n ố 5 Figure 2-4 ObJect Oriented Programming (OOP) Lc HH ng re 5 Figure 2-5 algorithm reSuÏ(s - - cành HH1 010 Tn HH HH HH HH HH HH Ho 6 I0 0201.000.0888 ng ốố ố 8 Figure 2-7 Encapsulat1on -‹- HH HH0 HH HH HH HH HH HH HH HH HH 8 Is0.80 si x8 8

FIigure 2-9 PolymorplÏiism 2c c1 11111221 111111211111110111 111111111111 HH1 111101111 kg 8

Figure 2-10 Example about text editor 1n VIisual studlo che 11 Figure2-II This 1s a debugger 1n Visual studl6 nh 221gr, 1 Figure2-12 Debugging in Visual studio occ siesta 12 Figure2-13 Debugging in VIsual stud1o HH HH HH HH HH Hài 12 Figure 2-14 Several lanpuages are supported in VIsual Študo - ào 13 I8 L8) An n ố 15 Figure 3-2 Create I€w DTOJ€CE HH HH1 111 1111 1H H11 kg 16 I6 0n .a 17 Figure 3-4 Adding elements to Íorim án 2219111 1 1011201 0 HH HH HH này 18 I5) 9i 2094) NN 22 Figure 3-6 Example of IDE proJ€c( sánh HH ng HH HH nhà Hi tho 22 I0 nh ốc 23 Figure 3-8 Create a new project or Open project cà nh 221tr ai 24 Figure 3-9: Create a I€wW DTOJ€CÍ HH H HH HH HH 1111111 25

Trang 9

Figure 3-10: Choose proJeet tempÌates ác nnn HH HH HH TH HH re, 26 Figure 3-11: Set the name of the new project and select a framework cee 26 Figure 3-12: Introduce workspace in Visual studio 0 ccc eeieneteseneenneeneenen 27 Figure 3-13 count the factorials from Ì fO 11 S1 1212111111221 11121211 HH HH Ho 27 Figure 3-14 Result 0.0 ồồÖ.a 28 Figure 3-15: Create a new Item 1n VIsual StUdHO - nh HH HH HH nu 28 Figure3-16: Create a mew 0u Tố 29 Figure3-L7 Workspace of class in Visual Študlo nga 29 Figure3- I8 Set breakpoimt In Visual stud1o ác ch HH HH HH Ho HH He 30 Figure3-19 How to follow the prfoBTaI tt H122 1112221111 H 11H Hà re 30 I0 60920010: 01005 0 Ầ 31 I0 c2 8n 32 I0 ) 0n Ố 36 Figure3-23 Program has fOr nh .- 39

Figure3-24 IDE debugger fñnd €fror - c2 2111111 12121111 1211111011 111101101 tre 39

Figure3-25 The program is out OŸ €TTOT c1 11111111111 111118111111211 1111101 110101111 11H 40 Figure3-26 For example nh e - Ầ 5 41 Figure 3-27 The program has a line of code with the wrong keyword eee 41 Figure 3-28 Symbolic of Coding standards - c t t1 nn n2 H11 11H Hà 46 Figure 3-29 Form Des1g St 3 211 1111112 1111211111111 1110211111111 47

II E61000.0i.00uo VN 48 I6 án 0n e5 49 I2 an 5 49

Trang 10

INTRODUCTION Programming is one of the subjects to master the knowledge base, understanding programming models such as procedural programming, object-oriented programming, and event-oriented programming, the structure of a program, data, basic data, at the same

time to introduce to students the knowledge of IDE, the functions of the IDE and some

standard rules, rules of naming in code At the same time, it helps students gain knowledge to build basic applications

This report includes the following:

CHAPTER 2 PROBLEMS RELATED TO PROGRAMMING METHODS AND IDE

LO2 Explain the characteristics of procedural, object-oriented and event driven

programming, conduct an analysis of a suitable Integrated Development Environment (IDE) CHAPTER 3 IDE problems, debugging procedures, and coding standards LO3 Implement basic algorithms in code using an IDE

LO4 Determine the debugging process and explain the importance of a coding standard

Trang 11

cm ‘BTEC

CHAPTER 2 PROBLEMS RELATED TO PROGRAMMING METHODS

AND IDE

LO2 Explain the characteristics of procedural, object-oriented and event-driven

programming, conduct an analysis of a suitable Integrated Development

Environment (IDE)

2.1 Give explanations of what procedural, object-oriented and event-driven

paradigms are;their characteristics and the relationship between them (P2)

+ Programming:

Programming is a job where programmers design, build, and maintain computer programs (software) People who do programming work are called programmers Using available code, programming languages, and utilities, they build, debug, or improve

programs, applications, games, software, websites, processing systems, and more

Help users interact with each other through electronic devices or execute commands with computers

2.1.1Procedure-Oriented Programming(POP):

POP is a way to establish information Procedural programming is the main focus

for completing tasks sequentially supporting the concept of procedure calling

Procedures (regular form or subroutine) simply contain a series of steps

Calculations be done Save control of the program's organizational flow If the

program is extensible, it is structured in a number of small units called functions,

which share data system-wide

| For example: Create a recursive function to calculate the factorial of a

number The first is to create the main function:

Perfomed Student LE TRAN QUOC BAO

Trang 12

ReadLine();

When running the program will get results

AMING\DEMO1\c asm\code asm\bin\Debug\code asm.exe

Click the button on the screen

Press the key on the keyboard

Hover

Timeout

Receive sensor output signal

Receive messages from other programs or threads

+ For example: Generate electricity bill

Trang 13

O Iuse the "TextBox" to enter the A and B values and print them out, and the " Button" to click the result and delete the result Data A when entering them should enter a non-zero number if entering 0 it will say "Or enter another 0"

The example below will show us

int a = int Parse(txta.Text);

if (a > b) txtketqua.Text = a.ToString();

txtketqua.Text = b.ToString();

¬

int a= int

int b = int P

private void bt3_CLick(object sender, EventArgs e)

private void Fo ễLoad(object sender, E

i

Trang 14

FIND THE BIGGEST NUMBER SN, ‘ge u

NHAP CHON TIM

INPUT Ajg > MAX2

INPUT B/g

MAX3

INPUT C

RESULT fe DELETE QAR EXIT

FIND THE BIGGEST NUMBER

NHAP CHON TIM

INPUT A 7

MAX2 INPUT B9

: MAX3 INPUT C3

DELETE QS EXIT

Figure2-3 Result

Trang 15

2.1.3 Object-oriented programming (OOP)

sa Object-Oriented Programming (OOP):

Object-oriented programming is a programming approach based on the concept of classes and objects OOP is more focused on objects rather than exploiting logic to

manipulate them, making code manageable, reusable, and maintainable is a programming

approach based on the concept of classes and objects OOP focuses on objects rather than the logic for manipulating them

Figure2-4 Object Oriented Programming (OOP)

+ For example: write simple student management programs:

first create a new class and initialize the student properties:

Trang 16

Figure2-5 algorithm results

2.1.4 Characteristics of the programming

models Procedural programming:

While designing a program, POP follows a top-down programming order

most functions allow system-wide data to be shared

It will divide larger programs into smaller parts called functions

It allows data to move freely in the system

Data is converted by available programs from one form to another

Procedural Programming advantage)

Provides the ability to reuse the same code in different places and at any time

Facilitates in program flow management

Capable of building modules

O Recursive method: Recursion is a declarative method, in its body it calls itself there is always

a stopping condition called “anchor point” When the anchor point is reached, the function will no longer call itself When called, the recursive function is usually passed one parameter, usually the size of the original large problem After each recursive call, the parameter will get smaller, to reflect the already smaller and simpler problem When the parameter reaches a minimum value (at the

anchor point), the function terminates

Trang 17

+ Event-driven programming:

UO Service-oriented: Since it consumes less power on the computer's preessing power and the services normally run in the operating platform, this feature is used to write programs that render services and do not slow the computer down Event-driven programming is the dominant paradigm used in graphical user interfaces and other applications (e.g JavaScript web apps) that focus on performing certain actions in response to input user input The same is true for device driver programming in an event-driven application, which typically has a main loop that listens for events and then fires a callback function when one of those

events is detected In embedded systems, the same can be achieved using hardware

interrupts instead of a continuously running main loop Event-driven programs can be written in any programming language, although the task is easier in languages that provide

a high degree of abstraction, such as await and closures

O Events: Are keyboard, mouse, interface, If we want events to happen, we have to activate

them

+ Simplicity of Programming and Ease of Development

The development of the ideas of structured and event-driven programming has greatly increased the productivity of programmers and has been able to create hundreds of lines of applications in a reasonable time frame Because of that, this technology is talked about in all educational settings related to computer settings If you are facing this topic for the first

time and understand the essence of the concept, we recommend that you read our articles -

we will tell you about event setup in simple ways We also provide coursework, semester papers, thesis support on all computer science topics

+ Object-Oriented Programming

Object-Oriented Programming has four basic properties: inheritance, polymorphism,

encapsulation, and abstraction

O Characteristics of the properties:

Abstraction: is the ability of the program to ignore or not pay attention to some edges of the information it is directly working on, which means it has the ability to focus on the core requirements Each object server as a "dynamic" can complete all

tasks in a way that content, reports, changes its state, and communicates with other

objects without knowing how make the progress performed by the operations This quality is normal call to the data object

(1)https://codedocs.org/what-is/event-driven-programming

Trang 18

Figure2-6:

Abstraction

L]

Encapsulation: This property does = notallow the user of the object to change the internal state of an object Only the internal methods of the object

Class

ace at >

Variables tx «+ Methods

allow to change its state How the external environment is allowed to affect an

object's internal data is entirely up to the coder This property ensures the integrity

properties without having to redefine them However, not all object-oriented

languages have this property

This means that the parent class can share data and methods among classes Subclass

from must be DEFINITION, outsiders can extend inherited elements and add new ones Reuse source code Optimize one way, make use of source code

Class A Class C

Figure2-8 Inheritance

Trang 19

O Polymorphism: Expressed through sending messages (message) Sending

these messages is comparable to calling the internal functions of an object The methods used to respond to a message will respond differently depending on the object to which the message is sent The programmer can define a property (by method names, for example) for a series of close-by objects, but when implemented using the same name, the implementation of each object will be automatic occurs according to the characteristics of each object without

confusion

Figure2-9 Polymorphism

2.1.5 What is the difference between procedural programming (POP) and object-ori-

ented programming (OOP)

BASIS FOR

POP COMPARISON

Basic Procedure/Structure oriented

Main focus is on "how to get the task done”

i.e on the procedure or structure of a program

Large program is divided into units called

Entire program is divided into objects

Access specifier are "public", "private",

"protected".

Trang 20

Neither it overload functions nor operators

Their is no provision of inheritance

There is no proper way of hiding the data, so

data is insecure

Global data is shared among the functions in

the program

No concept of friend function

No concept of virtual classes

Inheritance achieved in three modes public

private and protected

Data is hidden in three modes public, private, and protected hence data security increases

Data is shared among the objects through the member functions

Classes or function can become a friend of another class with the keyword "friend" Note: "friend” keyword is used only in c++

Concept of virtual function appear during

inheritance

C++, JAVA, VB.NET, C#.NET.

Trang 21

2.2 Analyze the common features that a developer has access to in an IDE(M2)

2.2.1 IDE definition: IDE (short for Integrated Development Environment) integrated environment used to write, develop code for applications

Os In addition, the IDE is also integrated with other support tools such as compiler, error

checking, information service, directory organization code, search code, formatting

highlight code IDE will make it more convenient and easier for you to develop applications without an IDE At that time, you can still write the source code, because

in fact, the source code of a certain programming language can run, you just need the corresponding compiler of that language itself

O = =The IDE also has a compiler or interpreter built into it From there, it helps you to execute code directly while programming the application Typically: Visual Studio,

Eclipse, Xcode, Android Studio,

2.2.2 Basic features of common IDE:

L] Text editor: code editor is a feature designed to write and edit code

Figure 2-10 Example about text editor in Visual studio

[] Debugger: Debugging tools help programmers identify errors in the source code When there is an error, it will report the error to the programmer and indicate the error line so that the programmer knows and corrects the error

Trang 22

Read()

Figure 2-11 This is a debugger in Visual studio

L] Compiler: is the component that translates from this programming language into a computer-processable language, such as binary code

L] Code completion: Full code features help programmers by intelligently detecting and adding common code elements These features help developers save coding time and reduce syntax capabilities law

Figure 2-12 Debugging in Visual studio

Trang 23

Figure 2-13 Debugging in Visual studio

L1 Programming language support: IDEs are typically specific to one programming language, however, some applications such as Sublime Title and Visual Studio are supported in multiple languages Before we go into coding, we need to find out the language we want to use and then choose a suitable IDE

Create a new project

† templates

Figure 2-14 Several languages are supported in Visual Studio

Trang 24

O The IDE allows developers to start setting up new applications quickly because many add-ons do not need to be configured and are actively manual as part of the setup process Developers also don't need to spend time learning how to use different tools

when all utilities are combined into one

This can be special owner is help the new member settings, these people can rely on the IDE to get up to speed on specified tools and jobs In fact, most of the IDE's features are aimed at saving time, like smart code completion and code auto- generation, eliminating the whole string character problem

Ol Various feature popular IDEs are intended to help developers organize their processes and solve problems IDE parsing code when it was writing, because that the error give

up by the HUMAN was identified in quick time

Trang 25

CHAPTER 3 IDE problems, debugging procedures, and

coding standards

LO3 Implement basic algorithms in code using an IDE

LO4 Determine the debugging process and explain the importance of a coding standard

3.1 Write a program that implements an algorithm using an IDE(P3)

% | will write an event-driven program that creates a Windows form to manage employee information First, I will talk about the properties of the components that I will use to write the program:

% J write software to manage employee information and find employee information, it includes:

Enter information: Staff code, full name, date of birth, hometown, Age, Gender, salary

L] In the information section, I use 3 buttons "Button" The first button I named " Additional" is used to add the data I entered above into the system, the second

button is named "Amend" it has a function to correct information when we fill in

the wrong information, the third button is called "Delete" it has the function of

de- leting information on the system we entered

O Iuse the "TextBox" button to record the employee's information and there is a

"DateTime picker" button that has the function to select the date of the year

Find employee information by searching by hometown, Gender, hometown

In the search section, I use the "checkBox" button to mark the information I need

to search and I also use the "Button" button called "search" it has the function of

searching for data information on the system the system that I entered earlier in

the information section

These are the steps I took to create a cinema simulation from Visual Studio software

LI Step 1: Create a new Project

Trang 26

Configure your new project

Console App (.NET Framework) © Windows

Nam eked

Figure 3-1 Main interface

UO Step 2: when entering the previously created project, we will create window forms

in that project I will show you the steps to do it with pictures as follows

First we right click on ConsoleApp1

Trang 27

After selecting the Form (window form) it will ap+pear a table for us to name the project

O Step 3: Enter a name for the project Here I will default to the initial name is :Form1.cs and click Add

Figure 3-2 Create new project

LI Step 4: In the Properties section of the Form you can change the Text as you like, this is the title of the software Will appear in the upper left corner of the form Here

I will leave the default as Form1

Trang 28

Figure 3-3 Main Form

O Step 5: You add the necessary components to the Form, here I will add Label,

TextBox, Button, Datatimepicker, Panel, ComboBox , and checkBox (These

components are in the ToolBox section)

#; Chương trình đặt vệ xem phim [i=l fee

movie ticket booking program

Trang 29

O Step 6: To edit you can edit in the Properties of the components

Figure 3-5: Element properties

Li Step 7: After preparing the interface, I start to code You double click on the button!

Einanespace Ba137 t i=0;i<pnGhe Cc

NI SE

bLGhe TextALign

1bLGhe.Width = L pn€he.ControLs.A ghe++;

1bLGhe.CLick +=

d(this Listofcustom

eø.Windows.Forn:

abeL LbLGhe = sender as

Ngày đăng: 03/05/2025, 12:52