Alice 2.0 an introduction to computer programming

Preview:

Citation preview

Alice 2.0Alice 2.0

an introduction to computer programmingan introduction to computer programming

Alice 2.0Alice 2.0

Part I: What is Alice?Part I: What is Alice?

Part II: Software DevelopmentPart II: Software Development

Part III: Elements of ProgrammingPart III: Elements of Programming

Part IV: Event-Driven ProgrammingPart IV: Event-Driven Programming

Part I: What is Alice?Part I: What is Alice?

What is Alice 2.0?What is Alice 2.0?

It is a computer application...

created by Carnegie Mellon University,

to “teach” computer programming.

Alice 2.0 is designed to create computer applications –

(i.e. build programs).

Who should use Alice?Who should use Alice?

Anyone interested in learning the underlying skills required for programming in most languages.

And All of YOU lucky CS109 students in this class!

Why use Alice?Why use Alice?Why not just jump into C++ or Java?Why not just jump into C++ or Java?

Alice makes learning programming easier…

removing the challenges of programming syntax,

and “debugging” is made easier with visual cues.

//c++ application

int main(0)

{

char display[20];

getline (display,20,\n);

cout>>display;

return;

}

What type of programming does Alice What type of programming does Alice teach?teach?

Alice utilizes the concepts of OOP (Object Oriented Programming),

and Event Driven Programming (i.e. an “event trigger” causes a series of commands/instructions to be exectuted).

Object BasicsObject Basics Objects have properties (description)

Object BasicsObject Basics Objects have methods (behaviors)

Note: functions are a method that returns a value.

Method (code) to make beak open and close

The Alice IDE The Alice IDE (integrated development environment)(integrated development environment)

ororsimply put – The Alice Interfacesimply put – The Alice Interface

This is the work area for programming with Alice…

The IDEThe IDE

Object Tree

Now you know what Alice is…Now you know what Alice is…the end (Part I)the end (Part I)

Time to try out Alice…Time to try out Alice…

Part II: Software DevelopmentPart II: Software Development

It’s not just Alice anymore.It’s not just Alice anymore.

The Software Development CycleThe Software Development Cycle

1. Design Phase1. Design Phase

In the Design Phase, information is In the Design Phase, information is gathered to determine the gathered to determine the task/problem to be solved by the task/problem to be solved by the application.application.

The task/problem is broken into smaller The task/problem is broken into smaller tasks, called modules.tasks, called modules.

Then a “plan of attack” is created.Then a “plan of attack” is created.

The Software Development CycleThe Software Development Cycle

2. Implementation Phase2. Implementation Phase

In the Implementation Phase, the In the Implementation Phase, the solution to the problem/task is coded solution to the problem/task is coded to build the application.to build the application.

The Software Development CycleThe Software Development Cycle

3. Testing Phase3. Testing Phase

In the Testing Phase, the application is In the Testing Phase, the application is tested –tested –

Individual modulesIndividual modules

Combined modulesCombined modules

Entire applicationEntire application

The Software Development CycleThe Software Development Cycle

4. Debugging Phase4. Debugging Phase

In the Debugging Phase,In the Debugging Phase,

The errors and side effects The errors and side effects (unwanted results)(unwanted results) are corrected.are corrected.

The Software Development CycleThe Software Development Cycle

5. Documentation5. Documentation

Finally, once the application works as Finally, once the application works as required by the Design Phase – the required by the Design Phase – the application and its workings are application and its workings are documented –documented –

for users of the applicationfor users of the applicationfor future programmers to modify the for future programmers to modify the

applicationapplication

Now you know the software Now you know the software development cycle…the end (Part II)development cycle…the end (Part II)

Part III: Elements of ProgrammingPart III: Elements of Programming

Programming Rule #1Programming Rule #1Algorithm: A step by step method for solving a problem

Programs are algorithms created to solve problems.

Thus, programs are linear –

They start at the top (beginning)

and

proceed to the bottom (end).

Key Programming CommandsKey Programming Commands

Selection/Branching – if/else (decision point or multiple points)

Do you want

a glass of milk?

Make glass of

milk

milk

choc

straw

Make c

Make s

Make plain

Key Programming CommandsKey Programming Commands

Repetition/Looping – loop & while (repeating a task)

Loops can be pre-test, or post-test

Key Programming CommandsKey Programming CommandsAre you Boolean Logical?

Boolean values are easy, as there are only 2.

0 – off/false

1 – on/true

Logic Operators:

==, <,<=, >,>=, !=

Now you know the key elements to Now you know the key elements to programming…the end (Part III)programming…the end (Part III)

Part IV: Event-Driven ProgrammingPart IV: Event-Driven Programming

In order to cause an “event” to occur – the user must invoke the “event trigger”.

Events & MethodsEvents & Methods

The event – chicken rolling and changing colors (as defined by the method “Silly Chicken”) “occurs” when the “event trigger” (mouse click on chicken) is detected by the “event listener”.

Note: The Silly Chicken method is known as the “event handler”.

Adding a BillboardAdding a Billboard

Billboards are used in Alice to list Billboards are used in Alice to list keyboard controls (event triggers) keyboard controls (event triggers) available to the user.available to the user.

1.1. Create the control billboard using Paint Create the control billboard using Paint 2.2. Use a textbox in Paint to list the Use a textbox in Paint to list the

commands of your Alice Worldcommands of your Alice World3.3. Save the file as a .jpgSave the file as a .jpg4.4. Import and use the file as listed on pages Import and use the file as listed on pages

220 -223220 -223

Time to try out Alice…Time to try out Alice…and explore the world of and explore the world of

programming!programming!