Talk Like a Pirate David Reed Creighton University davereed@creighton.edu www.creighton.edu/~davereed - PowerPoint PPT Presentation

About This Presentation
Title:

Talk Like a Pirate David Reed Creighton University davereed@creighton.edu www.creighton.edu/~davereed

Description:

Talk Like a Pirate. David Reed. Creighton University ... 'hello', 'ahoy', 'pardon me', 'avast', 'excuse me', 'arrr'], ['People' ... – PowerPoint PPT presentation

Number of Views:227
Avg rating:3.0/5.0
Slides: 7
Provided by: Dave4
Category:

less

Transcript and Presenter's Notes

Title: Talk Like a Pirate David Reed Creighton University davereed@creighton.edu www.creighton.edu/~davereed


1
Talk Like a PirateDavid ReedCreighton
Universitydavereed_at_creighton.edu
www.creighton.edu/davereed
2
Talk Like a Pirate Day
  • International Talk Like a Pirate Day September
    19th
  • founded by John Baur and Mark Summers in 1995
  • popularized by columnist Dave Barry
  • see www.talklikeapirate.com for more details
  • official Web site had a simple pirate translator
  • poorly done, but inspiring
  • "nifty" characteristics
  • can be used to introduce/demonstrate a variety of
    programming concepts
  • GUI
  • event-driven programming
  • meta-programming
  • string methods, regular expressions
  • can be used in a variety of classes using
    different languages
  • CS0 with HTML/JavaScript
  • CS1 or CS2 with C/Java
  • Web Design/Programming
  • it's fun!

3
Pirate Translator (version 1.0)
  • used in a Web-based CS0 course
  • students critiqued the design of the official
    page
  • developed a "better" translation page
  • one button per word/phrase
  • when user clicks on button, translation appears
    in a text box
  • ltinput type"button" value"hello"
    onClick"document.PForm.Output.value 'ahoy '"
    /gt
  • advantages
  • simple intuitive
  • easy to extend (just add more buttons)
  • minimal "programming"
  • open for creativity (layout, images, extended
    vocabulary, )

note this could easily be done in Java using
AWT/Swing
4
Pirate Translator (version 2.0)
  • disadvantage of version 1 button repetition
  • adding a new word/phrase meant adding a new
    button danger of inconsistencies
  • more general solution metaprogramming
  • store words/phrases in a list structure
  • to extend the vocabulary, simply add to the list
  • use JavaScript to dynamically generate the buttons

PHRASES "Greetings", "hello",
"ahoy", "pardon me", "avast", "excuse me",
"arrr", "People",
"sir", "matey", "madam", "proud beauty", "miss",
"comely wench", "Questions",
"where is", "whar be", "can you help me
find", "know ye", "is that", "be
that", "how far is it to", "how many leagues
to", . . . for (var
i 0 i lt PHRASES.length i)
document.write("lttr valign'top'gtlttdgt"
PHRASESi0 " lttdgt") for (var j
1 j lt PHRASESi.length j2)
document.write("ltinput type\"button\" value\""
PHRASESij "\"
onClick'document.PirateForm.Output.value \""
PHRASESij1 "
\"'gt\n")
could use a Java/C program to generate the HTML
document
5
Pirate Translator (version 3.0)
  • disadvantage of version 2 translation is limited
    to provided buttons
  • would like to take entire phrases, translate
    "piratey" parts, leave rest alone
  • alternative approach used in upper-level Web
    Programming course
  • user enters text to be translated
  • string methods used to search for words/phrases
    to translate
  • utilize regular expressions to match word
    boundaries, ignore case
  • replace matched word/phrase with pirate
    translation

PHRASES "hello", "ahoy", "hi", "yo-ho-ho",
"pardon me", "avast", "excuse me",
"arrr", "yes", "aye", "my", "me",
... for (var i 0 i lt
PHRASES.length i) var toReplace new
RegExp("\\b"PHRASESi0"\\b", "i")
var index text.search(toReplace) while
(index ! -1) if (text.charAt(index) gt "A"
text.charAt(index) lt "Z") text
text.replace(toReplace, Capitalize(PHRASESi1))
else text
text.replace(toReplace, PHRASESi1)
index text.search(toReplace)
here in JavaScript, but could be any language
with strings (regular expressions a plus)
6
It be fun!
  • in conclusion
  • a pirate translator is fun and engaging
  • can be used in a multiple courses to illustrate
    multiple concepts
  • can provide an open-ended challenge to students
  • critique/design a user interface
  • add to the vocabulary of the translator
  • add new features
  • e.g., insert random Arrrrrrr's
  • explore regular expressions
  • e.g., translate words ending in ing to in' (but
    not swing or handspring)

Give it a try in your class, or walk the
plank like the lily-livered landlubber you are!
Write a Comment
User Comments (0)
About PowerShow.com