SlideShare une entreprise Scribd logo
1  sur  56
Chapter 3 Working with Objects, Strings, and Variables Ruby Programming
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Objectives Ruby Programming 3-
Project Preview: The Ruby Virtual Crazy 8 Ball Game   Ruby Programming 3-
The Ruby Virtual Crazy 8 Ball Game (continued) ,[object Object],Ruby Programming 3- Figure 3-1 The welcome screen for the Ruby Virtual Crazy 8-Ball game.
The Ruby Virtual Crazy 8 Ball Game (continued) ,[object Object],Ruby Programming 3- Figure 3-2 The game requires the player to agree to play.
The Ruby Virtual Crazy 8 Ball Game (continued) ,[object Object],Ruby Programming 3- Figure 3-3 The game invites the player to return and play again.
The Ruby Virtual Crazy 8 Ball Game (continued) ,[object Object],Ruby Programming 3- Figure 3-4 The game prompts the player to ask it a question.
The Ruby Virtual Crazy 8 Ball Game (continued) ,[object Object],Ruby Programming 3- Figure 3-5 The game provides a randomly selected answer to the player’s question .
The Ruby Virtual Crazy 8 Ball Game (continued) ,[object Object],Ruby Programming 3- Figure 3-6 The player has the option of asking another question or typing q to quit the game.
The Ruby Virtual Crazy 8 Ball Game (continued) ,[object Object],Ruby Programming 3- Figure 3-7 The Ruby Virtual Crazy 8-Ball game has ended.
Creating and Formatting Text Strings Ruby Programming 3-
Modifying Text String Format ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Ruby Programming 3-
Modifying Text String Format   (continued) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Ruby Programming 3-
String Interpolation ,[object Object],[object Object],[object Object],[object Object],Ruby Programming 3-
Manipulating String Contents Ruby Programming 3-
Concatenating Text Strings  ,[object Object],[object Object],[object Object],[object Object],Ruby Programming 3-
Multiplying Text Strings ,[object Object],[object Object],[object Object],[object Object],Ruby Programming 3-
Comparing Text Strings  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Ruby Programming 3-
Creating Multiline Text Strings ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Ruby Programming 3-
Working with String Class Methods  Ruby Programming 3-
String Class Methods  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Ruby Programming 3-
Object-Oriented Programming  Ruby Programming 3-
Defining a New Class  ,[object Object],[object Object],[object Object],[object Object],[object Object],Ruby Programming 3-
Defining Class Properties  ,[object Object],[object Object],[object Object],[object Object],[object Object],Ruby Programming 3-
Instantiating and Interacting with New Objects  ,[object Object],[object Object],Ruby Programming 3-
Defining Class Methods  ,[object Object],[object Object],[object Object],[object Object],Ruby Programming 3-
Inheritance  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Ruby Programming 3-
Inheritance (continued) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Ruby Programming 3-
Converting from One Class to Another  Ruby Programming 3-
Implicit Class Conversion  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Ruby Programming 3-
Explicit Class Conversion  ,[object Object],[object Object],Ruby Programming 3-
Storing and Retrieving Data Ruby Programming 3-
Naming Variables ,[object Object],[object Object],[object Object],Ruby Programming 3-
Variable Assignments ,[object Object],[object Object],[object Object],[object Object],Ruby Programming 3-
Variable Scope ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Ruby Programming 3-
Storing Data That Does Not Change  Ruby Programming 3-
Constants ,[object Object],[object Object],[object Object],Ruby Programming 3-
Back to the Ruby Virtual Crazy 8 Ball Game  Ruby Programming 3-
Designing the Game ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Ruby Programming 3-
Step 1: Creating a New Ruby File  ,[object Object],[object Object],Ruby Programming 3-
Step 2: Documenting the Script and Its Purpose  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Ruby Programming 3-
Step 3: Defining a  Screen  Class ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Ruby Programming 3-
Step 4: Defining a  Ball  Class ,[object Object],[object Object],[object Object],[object Object],Ruby Programming 3-
Step 4: Defining a  Ball  Class  (continued) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Ruby Programming 3-
Step 4: Defining a  Ball  Class  (continued) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Ruby Programming 3-
Step 4: Defining a  Ball  Class  (continued) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Ruby Programming 3-
Step 5: Instantiating New Objects   ,[object Object],[object Object],[object Object],Ruby Programming 3-
Step 6: Greeting the Player  ,[object Object],[object Object],[object Object],[object Object],Ruby Programming 3-
Step 7: Prompting for Confirmation to Continue  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Ruby Programming 3-
Step 8: Analyzing the Player’s Response  ,[object Object],[object Object],[object Object],[object Object],Ruby Programming 3-
Step 9: Managing Early Termination of the Game ,[object Object],[object Object],[object Object],Ruby Programming 3-
Step 10: Responding to Player Questions  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Ruby Programming 3-
Step 10: Responding to Player Questions  (continued) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Ruby Programming 3-
Step 10: Responding to Player Questions  (continued) ,[object Object],[object Object],[object Object],Ruby Programming 3-
Running Your New Ruby Script Game  ,[object Object],[object Object],[object Object],[object Object],Ruby Programming 3-
Summary Ruby Programming 3- ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]

Contenu connexe

Tendances

Computer programming(CP)
Computer programming(CP)Computer programming(CP)
Computer programming(CP)nmahi96
 
Strings-Computer programming
Strings-Computer programmingStrings-Computer programming
Strings-Computer programmingnmahi96
 
Functions, Strings ,Storage classes in C
 Functions, Strings ,Storage classes in C Functions, Strings ,Storage classes in C
Functions, Strings ,Storage classes in Carshpreetkaur07
 
Functions-Computer programming
Functions-Computer programmingFunctions-Computer programming
Functions-Computer programmingnmahi96
 
C programming_MSBTE_Diploma_Pranoti Doke
C programming_MSBTE_Diploma_Pranoti DokeC programming_MSBTE_Diploma_Pranoti Doke
C programming_MSBTE_Diploma_Pranoti DokePranoti Doke
 
String Analysis for JavaScript Programs
String Analysis for JavaScript ProgramsString Analysis for JavaScript Programs
String Analysis for JavaScript ProgramsSerena King
 
JRuby, Not Just For Hard-Headed Pragmatists Anymore
JRuby, Not Just For Hard-Headed Pragmatists AnymoreJRuby, Not Just For Hard-Headed Pragmatists Anymore
JRuby, Not Just For Hard-Headed Pragmatists AnymoreErin Dees
 
Write Your Own JVM Compiler
Write Your Own JVM CompilerWrite Your Own JVM Compiler
Write Your Own JVM CompilerErin Dees
 
C programming session 05
C programming session 05C programming session 05
C programming session 05Dushmanta Nath
 
Class notes(week 5) on command line arguments
Class notes(week 5) on command line argumentsClass notes(week 5) on command line arguments
Class notes(week 5) on command line argumentsKuntal Bhowmick
 
Presentation 2nd
Presentation 2ndPresentation 2nd
Presentation 2ndConnex
 
12 computer science_notes_ch01_overview_of_cpp
12 computer science_notes_ch01_overview_of_cpp12 computer science_notes_ch01_overview_of_cpp
12 computer science_notes_ch01_overview_of_cppsharvivek
 
Your Own Metric System
Your Own Metric SystemYour Own Metric System
Your Own Metric SystemErin Dees
 
Unit 1 question and answer
Unit 1 question and answerUnit 1 question and answer
Unit 1 question and answerVasuki Ramasamy
 

Tendances (20)

Computer programming(CP)
Computer programming(CP)Computer programming(CP)
Computer programming(CP)
 
Strings-Computer programming
Strings-Computer programmingStrings-Computer programming
Strings-Computer programming
 
Functions, Strings ,Storage classes in C
 Functions, Strings ,Storage classes in C Functions, Strings ,Storage classes in C
Functions, Strings ,Storage classes in C
 
Functions-Computer programming
Functions-Computer programmingFunctions-Computer programming
Functions-Computer programming
 
C programming_MSBTE_Diploma_Pranoti Doke
C programming_MSBTE_Diploma_Pranoti DokeC programming_MSBTE_Diploma_Pranoti Doke
C programming_MSBTE_Diploma_Pranoti Doke
 
String Analysis for JavaScript Programs
String Analysis for JavaScript ProgramsString Analysis for JavaScript Programs
String Analysis for JavaScript Programs
 
Structures-2
Structures-2Structures-2
Structures-2
 
Let's us c language (sabeel Bugti)
Let's us c language (sabeel Bugti)Let's us c language (sabeel Bugti)
Let's us c language (sabeel Bugti)
 
C –FAQ:
C –FAQ:C –FAQ:
C –FAQ:
 
JRuby, Not Just For Hard-Headed Pragmatists Anymore
JRuby, Not Just For Hard-Headed Pragmatists AnymoreJRuby, Not Just For Hard-Headed Pragmatists Anymore
JRuby, Not Just For Hard-Headed Pragmatists Anymore
 
Write Your Own JVM Compiler
Write Your Own JVM CompilerWrite Your Own JVM Compiler
Write Your Own JVM Compiler
 
C programming session 05
C programming session 05C programming session 05
C programming session 05
 
C language 3
C language 3C language 3
C language 3
 
Class notes(week 5) on command line arguments
Class notes(week 5) on command line argumentsClass notes(week 5) on command line arguments
Class notes(week 5) on command line arguments
 
C_plus_plus
C_plus_plusC_plus_plus
C_plus_plus
 
Presentation 2nd
Presentation 2ndPresentation 2nd
Presentation 2nd
 
12 computer science_notes_ch01_overview_of_cpp
12 computer science_notes_ch01_overview_of_cpp12 computer science_notes_ch01_overview_of_cpp
12 computer science_notes_ch01_overview_of_cpp
 
C tutorials
C tutorialsC tutorials
C tutorials
 
Your Own Metric System
Your Own Metric SystemYour Own Metric System
Your Own Metric System
 
Unit 1 question and answer
Unit 1 question and answerUnit 1 question and answer
Unit 1 question and answer
 

En vedette

Unit D Digital Electronics and File Management
Unit D Digital Electronics and File ManagementUnit D Digital Electronics and File Management
Unit D Digital Electronics and File ManagementChaffey College
 
Predictive analytics-white-paper
Predictive analytics-white-paperPredictive analytics-white-paper
Predictive analytics-white-paperShubhashish Biswas
 
Unit G The Web and E-Commerce
Unit G The Web and E-CommerceUnit G The Web and E-Commerce
Unit G The Web and E-CommerceChaffey College
 
Java 8 - Nuts and Bold - SFEIR Benelux
Java 8 - Nuts and Bold - SFEIR BeneluxJava 8 - Nuts and Bold - SFEIR Benelux
Java 8 - Nuts and Bold - SFEIR Beneluxyohanbeschi
 
OCA Java SE 8 Exam Chapter 2 Operators & Statements
OCA Java SE 8 Exam Chapter 2 Operators & StatementsOCA Java SE 8 Exam Chapter 2 Operators & Statements
OCA Java SE 8 Exam Chapter 2 Operators & Statementsİbrahim Kürce
 
Cracking OCA and OCP Java 8 Exams
Cracking OCA and OCP Java 8 ExamsCracking OCA and OCP Java 8 Exams
Cracking OCA and OCP Java 8 ExamsGanesh Samarthyam
 
Analysis on the Business Model
Analysis on the Business Model Analysis on the Business Model
Analysis on the Business Model Roni Bhowmik
 

En vedette (8)

Unit D Digital Electronics and File Management
Unit D Digital Electronics and File ManagementUnit D Digital Electronics and File Management
Unit D Digital Electronics and File Management
 
Power point unit c
Power point unit cPower point unit c
Power point unit c
 
Predictive analytics-white-paper
Predictive analytics-white-paperPredictive analytics-white-paper
Predictive analytics-white-paper
 
Unit G The Web and E-Commerce
Unit G The Web and E-CommerceUnit G The Web and E-Commerce
Unit G The Web and E-Commerce
 
Java 8 - Nuts and Bold - SFEIR Benelux
Java 8 - Nuts and Bold - SFEIR BeneluxJava 8 - Nuts and Bold - SFEIR Benelux
Java 8 - Nuts and Bold - SFEIR Benelux
 
OCA Java SE 8 Exam Chapter 2 Operators & Statements
OCA Java SE 8 Exam Chapter 2 Operators & StatementsOCA Java SE 8 Exam Chapter 2 Operators & Statements
OCA Java SE 8 Exam Chapter 2 Operators & Statements
 
Cracking OCA and OCP Java 8 Exams
Cracking OCA and OCP Java 8 ExamsCracking OCA and OCP Java 8 Exams
Cracking OCA and OCP Java 8 Exams
 
Analysis on the Business Model
Analysis on the Business Model Analysis on the Business Model
Analysis on the Business Model
 

Similaire à Strings Objects Variables

Regular expressions
Regular expressionsRegular expressions
Regular expressionsRaghu nath
 
Cosc 1436 java programming/tutorialoutlet
Cosc 1436 java programming/tutorialoutletCosc 1436 java programming/tutorialoutlet
Cosc 1436 java programming/tutorialoutletWoodardz
 
Hub102 - JS - Lesson3
Hub102 - JS - Lesson3Hub102 - JS - Lesson3
Hub102 - JS - Lesson3Tiểu Hổ
 
Hw1 rubycalisthenics
Hw1 rubycalisthenicsHw1 rubycalisthenics
Hw1 rubycalisthenicsshelton88
 
Ggplot2 work
Ggplot2 workGgplot2 work
Ggplot2 workARUN DN
 
Exercise1[5points]Create the following classe
Exercise1[5points]Create the following classeExercise1[5points]Create the following classe
Exercise1[5points]Create the following classemecklenburgstrelitzh
 
Input processing and output in Python
Input processing and output in PythonInput processing and output in Python
Input processing and output in PythonMSB Academy
 
Input processing and output in Python
Input processing and output in PythonInput processing and output in Python
Input processing and output in PythonRaajendra M
 
Ruby introduction part1
Ruby introduction part1Ruby introduction part1
Ruby introduction part1Brady Cheng
 
Module 6 - String Manipulation.pdf
Module 6 - String Manipulation.pdfModule 6 - String Manipulation.pdf
Module 6 - String Manipulation.pdfMegMeg17
 
String handling and arrays by Dr.C.R.Dhivyaa Kongu Engineering College
String handling and arrays by Dr.C.R.Dhivyaa Kongu Engineering CollegeString handling and arrays by Dr.C.R.Dhivyaa Kongu Engineering College
String handling and arrays by Dr.C.R.Dhivyaa Kongu Engineering CollegeDhivyaa C.R
 
Introduction To Python
Introduction To  PythonIntroduction To  Python
Introduction To Pythonshailaja30
 
Notes3
Notes3Notes3
Notes3hccit
 
Python assignment 4
Python assignment 4Python assignment 4
Python assignment 4ANILBIKAS
 

Similaire à Strings Objects Variables (20)

Regular expressions
Regular expressionsRegular expressions
Regular expressions
 
Cosc 1436 java programming/tutorialoutlet
Cosc 1436 java programming/tutorialoutletCosc 1436 java programming/tutorialoutlet
Cosc 1436 java programming/tutorialoutlet
 
Python basics
Python basicsPython basics
Python basics
 
Hub102 - JS - Lesson3
Hub102 - JS - Lesson3Hub102 - JS - Lesson3
Hub102 - JS - Lesson3
 
Hw1 rubycalisthenics
Hw1 rubycalisthenicsHw1 rubycalisthenics
Hw1 rubycalisthenics
 
Ruby Programming
Ruby ProgrammingRuby Programming
Ruby Programming
 
Ggplot2 work
Ggplot2 workGgplot2 work
Ggplot2 work
 
Ruby
RubyRuby
Ruby
 
Exercise1[5points]Create the following classe
Exercise1[5points]Create the following classeExercise1[5points]Create the following classe
Exercise1[5points]Create the following classe
 
Input processing and output in Python
Input processing and output in PythonInput processing and output in Python
Input processing and output in Python
 
Input processing and output in Python
Input processing and output in PythonInput processing and output in Python
Input processing and output in Python
 
Ruby introduction part1
Ruby introduction part1Ruby introduction part1
Ruby introduction part1
 
Module 6 - String Manipulation.pdf
Module 6 - String Manipulation.pdfModule 6 - String Manipulation.pdf
Module 6 - String Manipulation.pdf
 
UNIT II (7).pptx
UNIT II (7).pptxUNIT II (7).pptx
UNIT II (7).pptx
 
UNIT II (7).pptx
UNIT II (7).pptxUNIT II (7).pptx
UNIT II (7).pptx
 
String handling and arrays by Dr.C.R.Dhivyaa Kongu Engineering College
String handling and arrays by Dr.C.R.Dhivyaa Kongu Engineering CollegeString handling and arrays by Dr.C.R.Dhivyaa Kongu Engineering College
String handling and arrays by Dr.C.R.Dhivyaa Kongu Engineering College
 
Introduction To Python
Introduction To  PythonIntroduction To  Python
Introduction To Python
 
Notes3
Notes3Notes3
Notes3
 
18 ruby ranges
18 ruby ranges18 ruby ranges
18 ruby ranges
 
Python assignment 4
Python assignment 4Python assignment 4
Python assignment 4
 

Plus de Chaffey College (20)

Social networks and games
Social networks and gamesSocial networks and games
Social networks and games
 
Serious games
Serious gamesSerious games
Serious games
 
Chapter 05
Chapter 05Chapter 05
Chapter 05
 
Chapter 04
Chapter 04Chapter 04
Chapter 04
 
Chapter 03
Chapter 03Chapter 03
Chapter 03
 
The games factory 2 alien wars
The games factory 2 alien warsThe games factory 2 alien wars
The games factory 2 alien wars
 
Target markets
Target marketsTarget markets
Target markets
 
Ch 8 introduction to data structures
Ch 8 introduction to data structuresCh 8 introduction to data structures
Ch 8 introduction to data structures
 
Ch 8 data structures in alice
Ch 8  data structures in aliceCh 8  data structures in alice
Ch 8 data structures in alice
 
Ch 7 recursion
Ch 7 recursionCh 7 recursion
Ch 7 recursion
 
Intro to gml
Intro to gmlIntro to gml
Intro to gml
 
Power point unit d
Power point unit dPower point unit d
Power point unit d
 
Power point unit b
Power point unit bPower point unit b
Power point unit b
 
Power point unit a
Power point unit aPower point unit a
Power point unit a
 
Gamegraphics
GamegraphicsGamegraphics
Gamegraphics
 
Gamesound
GamesoundGamesound
Gamesound
 
Ch 6 text and sound in alice
Ch 6 text and sound in aliceCh 6 text and sound in alice
Ch 6 text and sound in alice
 
Ch 5 boolean logic
Ch 5 boolean logicCh 5 boolean logic
Ch 5 boolean logic
 
Ch 5 boolean logical in alice
Ch 5  boolean logical in aliceCh 5  boolean logical in alice
Ch 5 boolean logical in alice
 
Game maker objects
Game maker objectsGame maker objects
Game maker objects
 

Strings Objects Variables