Search Header Logo
OOP Lesson 1

OOP Lesson 1

Assessment

Presentation

Computers

University

Practice Problem

Easy

Created by

Karen Ahmed

Used 5+ times

FREE Resource

16 Slides • 7 Questions

1

Object-Oriented Programming

Lesson 1: Introduction to OOP

2

media

​What is Object-Oriented Programming?

3

​OOP in Action

  • The OOP paradigm is focussed on objects​ which represent parts of a computer program.

  • ​You can create objects to represent physical things, like a human being.

  • ​They can also be used for small parts of a larger program, like a widget in a user interface.

media

4

​Classes

  • To create objects, you must first define a class.​

  • ​A class is like a blueprint, it contains the plans for the data and behaviours an object should possess.

  • ​You can create many objects from a single class.

  • ​Just like you can make many houses from the same blueprint.

media

5

​Objects

  • You can use a class to create enemies in a video game.

  • ​One class details what information the enemies can hold and the behaviour it has.

  • ​Objects would be the actual enemies in the game.

  • ​Each ghost is an object in the game with a slightly different behaviour.

media
media

6

web page not embeddable

PACMAN with Turtle - Replit

You can open this webpage in a new tab.

7

​Object Behaviour

  • Ghost objects can choose their own behaviour based a the set of defined rules.

  • ​Each ghost has its own attributes: colour, speed, name.

  • ​They all move independently of each other.

media

8

​Classes and Objects

  • ​One of the classes used in this program is called turtle.

  • ​We import the class so that it can be used to make objects.

  • ​The objects created are: blinky, pinky, inky and clyde.

  • ​These are actually the variables used to store the objects.

media
media

9

Multiple Choice

A template used to create objects...

1

Subroutine

2

Function

3

Class

10

Multiple Choice

An instance of a class...

1

Object

2

Function

3

Variable

11

​Introduction to C#

media

12

​C#

This programming language can be used to make interactive websites, mobile apps, video games, augmented reality (AR), virtual reality (VR), desktop applications, and back-end services – just to name a few.

For example, the mobile game Pokemon Go and the Stack Overflow website were built with frameworks that can be run with C# (Unity and ASP.NET, respectively).

media

13

  • Unlike languages like Ruby and JavaScript, C# has you define the type of each data in a program.

  • Assigning a type essentially tells a computer what operations can and cannot be performed on a piece of data.

  • This style of coding helps programmers avoid a large class of errors that are common to Ruby and JavaScript.

​C# Data Types

media

14

​Hello World

Console.WriteLine() is a command that prints text to a console.

Whatever is in between the parentheses will be printed to the console!

In this case it’s Hello World!

Task: Start a new project in Visual Studio and change the code so that your own name is printed to the console!

media

15

web page not embeddable

HelloWorld - Replit

You can open this webpage in a new tab.

16

​Getting Input

We can also read input from a user. The command Console.ReadLine() captures text that a user types into the console.

In this example, the program writes a question to the console and waits for user input. Once the user types something and presses Enter (or Return), the input is printed back out to the user.

media
media

17

​Comments

Text written in a program but not run by the computer is called a comment.

In C#, anything after a // or between /* and */ is a comment.

Comments can:

Provide context for why something is written the way it is:

media

Help other people reading the code understand it faster:

media

Ignore a line of code and see how a program will run without it:

media

18

Multiple Choice

Question image

In C#, what are these lines of code called?

1

Output

2

Comments

3

Inputs

4

Commands

19

Multiple Choice

Question image

What is the outcome of these lines of code?

1

The text "Let's get started" is printed

2

No text is printed until the user types into the console

3

The text "Press Enter to begin..." and the computer waits for the user to press Enter

4

The texts "Press Enter to begin..." and "Let's get started!" are printed

20

Multiple Choice

Question image

What is the outcome of this line of code?

1

The computer waits for the user to type something

2

The computer outputs whatever the user last entered

3

The computer outputs "Console.ReadLine()"

4

The computer copies all of the text in the console

21

Multiple Choice

Question image

What is the outcome of this line of code?

1

The text WriteLine is printed

2

The text Console.WriteLine("Open Sesame!") is printed

3

The text "Open Sesame" is printed

4

No text is printed

22

Multiple Choice

What is NOT a good reason to use comments in your code?

1

Ignore a line of code to see how a program will run without it

2

Provide context why something is written the way it is

3

Help other people reading the code to understand it faster

4

To instruct a computer to execute a block of code

23

web page not embeddable

ConsoleCreatures - Replit

You can open this webpage in a new tab.

Object-Oriented Programming

Lesson 1: Introduction to OOP

Show answer

Auto Play

Slide 1 / 23

SLIDE