Tải bản đầy đủ (.pdf) (1,151 trang)

Introduction to computing and programming with java a mult

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (9.11 MB, 1,151 trang )




Tableof

Contents
• Index

IntroductiontoComputing&Programmingin
Java™:AMultimediaApproach
ByMarkGuzdial,BarbaraEricson-Collegeof
Computing/GVUGeorgiaInstituteofTechnology
Publisher :PrenticeHall
PubDate :April07,2006
PrintISBN-10 :0-13-049698-0
eTextISBN-10 :0-13-186044-5
eTextISBN-13 :978-0-13-186044-5
Pages :592


Usingthevideogamegeneration'sfascinationwithdigital
multimediaasaspringboard,thistextteachesJavaprogramming
inacontextthatstudentsfindrelevantanduseful.Studentslearn
toprogramusingJavawhilecreatinginterestingeffectswith
sounds,pictures,webpages,andvideo.




IntroductiontoComputing&Programmingin
Java™:AMultimediaApproach


ByMarkGuzdial,BarbaraEricson-Collegeof
Computing/GVUGeorgiaInstituteofTechnology
Publisher :PrenticeHall
PubDate :April07,2006

PrintISBN-10 :0-13-049698-0
Tableof

Contents eTextISBN-10 :0-13-186044-5
eTextISBN-13 :978-0-13-186044-5
• Index
Pages :592









































Copyright
TrademarkPage
Preface
AbouttheAuthors
AbouttheCDROM
Part1:Introduction
Chapter1.IntroductiontoComputerScienceandMedia
Computation

Section1.1.WhatisComputerScienceAbout?
Section1.2.WhatComputersUnderstand
Section1.3.MediaComputation:WhyDigitizeMedia?
Section1.4.ComputerScienceforEveryone
Problems
ToDigDeeper
Chapter2.IntroductiontoJava
Section2.1.Java
Section2.2.IntroductiontoDrJava
Section2.3.JavaBasics
Section2.4.Variables
Section2.5.ConceptsSummary
Problems
ToDigDeeper

vi
xxi
xxix
xxxi
1
2
2
7
9
10
11
13
14
14
16

19
25
33
35
37















































































Chapter3.IntroductiontoProgramming
Section3.1.ProgrammingisAboutNaming
Section3.2.FilesandTheirNames
Section3.3.ClassandObjectMethods
Section3.4.WorkingwithTurtles
Section3.5.CreatingMethods
Section3.6.WorkingwithMedia
Section3.7.ConceptsSummary

ObjectsandMethodsSummary
Problems
ToDigDeeper
Part2:Pictures
Chapter4.ModifyingPicturesUsingLoops
Section4.1.HowPicturesareEncoded
Section4.2.ManipulatingPictures
Section4.3.ChangingColorValues
Section4.4.ConceptsSummary
ObjectsandMethodsSummary
Problems
ToDigDeeper
Chapter5.ModifyingPixelsinaMatrix
Section5.1.CopyingPixels
Section5.2.CopyingandTransformingPictures
Section5.3.ConceptsSummary
ObjectsandMethodsSummary
Problems
ToDigDeeper
Chapter6.ConditionallyModifyingPixels
Section6.1.ConditionalPixelChanges
Section6.2.SimpleEdgeDetection:ConditionalswithTwo
Options
Section6.3.Sepia-TonedandPosterizedPictures:Using
MultipleConditionalstoChoosetheColor
Section6.4.HighlightingExtremes
Section6.5.CombiningPixels:Blurring
Section6.6.BackgroundSubtraction
Section6.7.Chromakey
Section6.8.ConceptsSummary

Problems

38
38
40
41
43
50
59
69
70
72
73
75
76
76
85
91
124
126
127
130
131
131
142
167
170
170
172
173

173
182
186
193
194
197
202
205
207

















































































Chapter7.Drawing
Section7.1.DrawingUsingtheGraphicsClass

Section7.2.ProgramsasSpecifyingDrawingProcess
Section7.3.UsingGraphics2DforAdvancedDrawing
Section7.4.ConceptsSummary
ObjectsandMethodsSummary
Problems
Part3:Sounds
Chapter8.ModifyingAllSamplesinaSound
Section8.1.HowSoundisEncoded
Section8.2.ManipulatingSounds
Section8.3.ChangingtheVolumeofSounds
Section8.4.NormalizingSounds
Section8.5.ConceptsSummary
ObjectsandMethodsSummary
Problems
ToDigDeeper
Chapter9.ModifyingSamplesUsingRanges
Section9.1.ManipulatingDifferentSectionsofaSound
Differently
Section9.2.CreateaSoundClip
Section9.3.SplicingSounds
Section9.4.ReversingaSound
Section9.5.MirroringaSound
Section9.6.ConceptsSummary
Problems
ToDigDeeper
Chapter10.MakingSoundsbyCombiningPieces
Section10.1.ComposingSoundsThroughAddition
Section10.2.BlendingSounds
Section10.3.CreatinganEcho
Section10.4.HowSamplingKeyboardsWork

Section10.5.AdditiveSynthesis
Section10.6.ModernMusicSynthesis
Section10.7.ConceptsSummary
Problems
ToDigDeeper
Chapter11.CreatingClasses
Section11.1.IdentifyingtheObjectsandFields

212
212
226
230
245
246
249
251
252
252
262
271
280
284
287
289
292
293
293
295
297
304

306
307
308
311
312
312
313
315
318
325
333
339
340
342
343
344










































































Section11.2.DefiningaClass
Section11.3.OverloadingConstructors

Section11.4.CreatingandInitializinganArray
Section11.5.CreatingAccessors(Getters)andModifiers
(Setters)
Section11.6.CreatingaMainMethod
Section11.7.JavadocComments
Section11.8.CreatingAnotherClass
Section11.9.ReusingaClassViaInheritance
Section11.10.ConceptsSummary
Problems
Part4:Text,Files,Networks,Databases,andUnimedia
Chapter12.CreatingandModifyingText
Section12.1.TextasUnimedia
Section12.2.Strings:CharacterSequences
Section12.3.Files:PlacestoPutYourStringsandOther
Stuff
Section12.4.OtherUsefulClasses
Section12.5.Networks:GettingOurTextfromtheWeb
Section12.6.UsingTexttoShiftBetweenMedia
Section12.7.ConceptsSummary
Problems
Chapter13.MakingTextfortheWeb
Section13.1.HTML:TheNotationoftheWeb
Section13.2.WritingProgramstoGenerateHTML
Section13.3.Databases:APlacetoStoreOurText
Section13.4.RelationalDatabases
Section13.5.ConceptsSummary
Problems
ToDigDeeper
Part5:Movies
Chapter14.Encoding,Manipulating,andCreatingMovies

Section14.1.GeneratingFrame-BasedAnimations
Section14.2.WorkingwithVideoFrames
Section14.3.ConceptsSummary
Problems
Part6:TopicsinComputerScience
Chapter15.Speed
Section15.1.FocusingonComputerScience

344
356
356
363
366
367
369
373
379
382
385
386
387
387
394
417
421
427
433
438
442
442

447
459
466
477
479
481
483
484
485
494
501
501
503
504
504





























































Section15.2.WhatMakesProgramsFast?
Section15.3.WhatMakesaComputerFast?
Section15.4.ConceptsSummary
Problems
ToDigDeeper
Chapter16.JavaScript:AWebPageProgrammingLanguage
Section16.1.JavaScriptSyntax
Section16.2.JavaScriptInsideofWebPages
Section16.3.UserInterfacesinJavaScript
Section16.4.MultimediainJavaScript
Section16.5.ConceptsSummary
Problems
ToDigDeeper
AppendixA.QuickReferencetoJava
SectionA.1.Variables
SectionA.2.MethodDeclarations

SectionA.3.Loops
SectionA.4.Conditionals
SectionA.5.Operators
SectionA.6.StringEscapes
SectionA.7.Classes
SectionA.8.Fields
SectionA.9.Constructors
SectionA.10.Packages
Bibliography
UsingtheStudentCD
IncludedontheCD
SystemRequirements
Installation
Index

504
522
525
525
528
529
529
531
534
540
541
541
542
543
543

544
546
547
547
548
548
549
549
549
551
InsideBackCover
InsideBackCover
InsideBackCover
InsideBackCover


Copyright
[Pageiv]
LibraryofCongressCataloging-in-PublicationData

Guzdial,Mark.
IntroductiontocomputingandprogramminginJava:amultimediaappr
GuzdialandBarbaraEricson.
p.cm.
Includesindex.
ISBN0-13-149698-0
1.Java(Computerprogramlanguage).2.Multimediasystems.I.Ericson
Title.
QA76.73J38G842005
005.13'3dc222005051335

VicePresidentandEditorialDirector,ECS:MarciaJ.Horton
ExecutiveEditor:TracyDunkelberger
AssistantEditor:CaroleSnyder
EditorialAssistant:ChristiannaLee
ExecutiveManagingEditor:VinceO'Brien
ManagingEditor:CamilleTrentacoste
ProductionEditor:DonnaCrilly
DirectorofCreativeServices:PaulBelfanti
ArtDirectorandCoverManager:JonathanBoylan
CoverDesigner:JonathanBoylan
ManagingEditor,AVManagementandProduction:PatriciaBurns
ManagingEditor,ArtProjectManagement:AbigailBass
ArtEditor:RhondaAversa
Director,ImageResourceCenter:MelindaReo
Manager,RightsandPermissions:ZinaArabia
Manager,VisualResearch:BethBrenzel


Manager,CoverVisualResearchandPermissions:KarenSanatar
ImagePermissionCoordinator:AngeliqueSharps
ManufacturingManager,ESM:AlexisHeydt-Long
ManufacturingBuyer:LisaMcDowell
ExecutiveMarketingManager:RobinO'Brien
©2007PearsonEducation,Inc.
PearsonPrenticeHall
PearsonEducation,Inc.
UpperSaddleRiver,NewJersey07458
Allrightsreserved.Nopartofthisbookmaybereproducedin
anyformorbyanymeans,withoutpermissioninwritingfrom
thepublisher.

PearsonPrenticeHall™isatrademarkofPearsonEducation,
Inc.
Theauthorandpublisherofthisbookhaveusedtheirbest
effortsinpreparingthisbook.Theseeffortsincludethe
development,research,andtestingofthetheoriesand
programstodeterminetheireffectiveness.Theauthorand
publishermakenowarrantyofanykind,expressedorimplied,
withregardtotheseprogramsorthedocumentationcontained
inthisbook.Theauthorandpublishershallnotbeliableinany
eventforincidentalorconsequentialdamagesinconnection
with,orarisingoutof,thefurnishing,performance,oruseof
theseprograms.
PrintedintheUnitedStatesofAmerica
10987654321
PearsonEducationLtd.,London
PearsonEducationAustraliaPty.Ltd.,Sydney
PearsonEducationSingapore,Pte.Ltd.


PearsonEducationNorthAsiaLtd.,HongKong
PearsonEducationCanada,Inc.,Toronto
PearsonEducacióndeMexico,S.A.deC.V.
PearsonEducationJapan,Tokyo
PearsonEducationMalaysia,Pte.Ltd.
PearsonEducation,Inc.,UpperSaddleRiver,NewJersey

[Pagev]

Dedication
DedicatedtoourchildrenMatthew,Katherine,and

Jennifer.




[Pagevi]


TrademarkPage
Adobe,MacromediaFlash,MacromediaSoundEdit,Photoshop,
andQuakeareregisteredtrademarksortrademarksofAdobe
SystemsIncorporatedintheUnitedStatesandothercountries.
Apple,FinalCutPro,andiMoviearetrademarksorregistered
trademarksofAppleComputer,Inc.
AutoCADisaregisteredtrademarkofAutodesk,Inc.intheUSA
and/orothercountries.
DOOMisaregisteredtrademarkofIdSoftware,Inc.
DrJavaisopen-sourcesoftware,©20012003bytheJavaPLT
groupatRiceUniversity().Allrightsreserved.
EudoraisaregisteredtrademarkofQUALCOMMIncorporatedin
theUnitedStatesandothercountries.
IntelisaregisteredtrademarkofIntelCorporationorits
subsidiariesintheUnitedStatesandothercountries.
JavaandallJava-basedtrademarksandlogosaretrademarks
orregisteredtrademarksofSunMicrosystems,Inc.intheU.S.
andothercountries.
LEGOisatrademarkoftheLEGOGroupofcompaniesinthe
UnitedStatesandothercountries.
MasterCardisaregisteredtrademarkofMasterCard
International,IncorporatedintheUnitedStatesandother

countries.
Microsoft,VisualBasic,Visio,PowerPoint,InternetExplorer,
Word,andOutlookareregisteredtrademarksofMicrosoft
CorporationintheUnitedStatesand/orothercountries.


NetscapeNavigatorisatrademarkofNetscapeCommunications
Corporation.
QuickenisatrademarkofIntuit,Inc.,registeredintheUnited
Statesandothercountries.
SqueakislicensedbyMIT,©2003byLucasRenggliand©2003
bySoftwareCompositionGroup,UniversityofBerne.
SuperMarioBrothersisaregisteredtrademarkofNintendoof
America,IncorporatedintheUnitedStatesandothercountries.
ToyotaCamryisaregisteredtrademarkofToyotaMotor
Corporation.
VISAisaregisteredtrademarkofVisaInternationalService
AssociationintheUnitedStatesandothercountries.


[Pagexxi]


Preface
Thisbookisintendedtointroducecomputing,including
programming,tostudentswithnopriorprogramming
experience.Oneofthelessonsfromtheresearchoncomputing
educationisthatonedoesn'tjust"learntoprogram."One
learnstoprogramsomething[4,17].Howmotivatingthat
somethingiscanmakethedifferencebetweenlearningto

programornot[6].Somepeopleareinterestedinlearning
programmingjustforprogramming'ssakebutthat'snotmost
people.
Unfortunately,mostintroductoryprogrammingbooksare
writtenasifstudentshaveaburningdesiretolearntoprogram.
Theyemphasizeprogrammingconceptsandgivelittlethought
tomakingtheproblemsthatarebeingsolvedinterestingand
relevant.Theyintroducenewconceptswithoutshowingwhythe
studentsshouldwanttoknowaboutthem.
Inthisbookstudentswilllearnaboutprogrammingbywriting
programstomanipulatemedia.Studentswillcreateandmodify
images,suchascorrectingfor"red-eye"andgenerating
negativeimages.Studentswillmodifysounds,likesplicing
wordsintosentencesorreversingsoundstomakeinteresting
effects.StudentswillwriteprogramstogenerateWebpages
fromdataindatabases,inthesamewaythatCNN.comand
Amazon.comdo.Theywillcreateanimationsandmoviesusing
specialeffectsliketheonesseenontelevisionandinmovies.
StudentsincoursestaughtatGeorgiaTechhavefoundthese
programsinterestingandmotivating.Studentshaveeven
reportedturningintheirprogramsandthencontinuingtowork
onthemtoseewhatelsetheycanmake.
Thisbookisaboutteachingpeopletoprograminorderto
communicate.Peoplewanttocommunicate.Wearesocial


creatures,andthedesiretocommunicateisoneofourprimal
motivations.Increasingly,thecomputerisusedasatoolfor
communicationevenmorethanasatoolforcalculation.
Virtuallyallpublishedtext,images,sounds,music,andmovies

todayarepreparedusingcomputingtechnology.Thisbook
focusesonhowtomanipulateimages,sounds,text,andmovies
asprofessionalsmight,butwithprogramswrittenbythe
students.
Werealizethatmostpeoplewilluseprofessional-grade
applicationstoperformthesesamemanipulations.Sowhylearn
toprogramthesemanipulationsyourself?Whynotjustleaveit
tothedevelopersofPhotoshopandiMovie?Theanswer
dependsonyourinterestsandcareerchoices.
Ifyouhaveaninterestinbecomingacomputing
professional,thenit'sworthwhileforyoutounderstandhow
tobuildprogramsusedincommunication.Muchofthe
softwareinthefuturewillbeusedforcommunications,so
thisisagreatdomaintostartlearningusefulskills.Most
computingclassestodayaretaughtinJava,sothisbook
presentstherightcontextforlearningprogrammingandin
therightlanguageforyou.
Ifyouexpecttobeauserofapplicationsinthefuture,
knowingsomethingofhowyourtoolsworkscanmakeyoua
so-called"PowerUser."Mostcommonapplicationstoday
aremuchmorepowerfulthanmostusersrealize.Many
communicationsapplicationsareactuallythemselves
programmablewithscriptinglanguagesthatenableusersto
automatetasksintheapplication.Touseallthefacilitiesof
anapplication,ithelpstohaveanunderstandingofwhat
theapplicationisdoingifyouknowwhatapixelis,youcan
understandbetterwhyit'susefultomanipulate.Tousethe
scriptingfacilitiesofanapplication,someknowledgeof
programmingisarequirement.



[Pagexxii]
Ifyouareacreativepersonwhowantscompletecontrolof
yourcommunications,youwanttoknowhowtodowithout
yourapplicationsifyouneedto,inordertoimplementyour
vision.Knowinghowtodomanipulatemediawithyourown
programsmeansthatyoucandowhatyouwant,ifyou
everneedto.Youmaywanttosaysomethingwithyour
media,butyoumaynotknowhowtomakePhotoshopor
FinalCutProdowhatyouwant.Knowinghowtoprogram
meansthatyouhavepowerofexpressionthatisnotlimited
byyourapplicationsoftware.
Finally,youmayhavenointerestinprogrammingyour
applications,orprogrammingatall.Isitworthwhileforyou
tolearnthisstuff?Studentswhotookourmedia
computationclassesatGeorgiaTechtoldusayearlater
thatthecoursewasrelevantintheirdailylife[15].Welive
inatechnologicalsociety,andmuchofthattechnologyis
usedtomanipulatewhatweseeandhearinourmedia.If
youknowsomethingofhowthattechnologyworks,you
haveawayofthinkingabouthowtouseit,andhowitmay
beusedtochangeyourperceptions.Studentswhoarenot
computersciencemajorstoldusayearafterfinishingthe
coursethattheynowhadanewconfidencearound
computersbecausetheyknewsomethingabouthowthey
worked[15].
Thisbookisnotjustaboutprogrammingtomanipulatemedia.
Mediamanipulationprogramscanbehardtowrite,orbehavein
unexpectedways.Questionsariselike"Whyisthissameimage
filterfasterinPhotoshop?"and"Thatwashardtodebugare

therewaysofwritingprogramsthatareeasiertodebug?"
Answeringquestionsliketheseiswhatcomputerscientistsdo.
Thelastchaptersattheendofthebookareaboutcomputing,
notjustprogramming(Chapters15and16).


Thecomputeristhemostamazinglycreativedevicethat
humanshaveeverconceivedof.Itisliterallycompletelymade
upofmind-stuff.Thenotion"Don'tjustdreamit,beit"isreally
possibleonacomputer.Ifyoucanimagineit,youcanmakeit
"real"onthecomputer.Playingwithprogrammingcanbeand
shouldbeenormousfun.

[Pagexxii(continued)]

ToTeachers
Themediacomputationapproachusedinthisbookstartswith
whatstudentsusecomputersfor:imagemanipulation,digital
music,Webpages,games,andsoon.Wethenexplain
programmingandcomputingintermsoftheseactivities.We
wantstudentstovisitAmazon(forexample)andthink,"Here's
acatalogWebsiteandIknowthatthisisimplementedwitha
databaseandasetofprogramsthatformatthedatabase
entriesasWebpages."Startingfromarelevantcontextmakes
transferofknowledgeandskillsmorelikely,anditalsohelps
withretention.

[Pagexxiii]
Themajorityofthebookspendstimegivingstudents
experienceswithavarietyofmediaincontextsthattheyfind

motivating.Afterthat,though,theystarttodevelopquestions.
"WhyisitthatPhotoshopisfasterthanmyprogram?"and
"Moviecodeisslowhowslowdoprogramsget?"aretypical.At
thatpoint,weintroducetheabstractionsandthevaluable
insightsfromcomputersciencethatanswertheirquestions.
That'swhatthelastpartofthisbookisabout.
Researchersincomputingeducationhavebeenexploringwhy
withdrawalorfailureratesincollege-levelintroductory
computingcourseshavebeensohigh.Therateofstudents


withdrawingfromcollege-levelintroductorycomputingcourses
orreceivingaDorFgrade(commonlycalledtheWDFrate)has
beenreportedinthe3050%range,orevenhigher.Oneofthe
commonthemesfromresearchintowhytheWDFrateisso
highisthatcomputingcoursesseem"irrelevant"and
unnecessarilyfocusingon"tediousdetails"suchasefficiency
[22,1].
However,studentshavefoundmediacomputationtobe
relevantasevidencedbysurveyresponsesandthereductionin
ourWDFratefromanaverageof28%to11.5%forthepilot
offeringofthiscourse.Spring2004wasthefirstsemester
taughtbyinstructorsotherthanMarkGuzdial,andtheWDF
ratedroppedto9.5%forthe395studentswhoenrolled.
CharlesFowleratGainesvilleCollegeinGeorgiahasbeen
havingsimilarresultsinhiscoursesthere.
Theapproachinthisbookisdifferentthaninmanyintroductory
programmingbooks.Weteachthesamecomputingconcepts
butnotnecessarilyintheusualorder.Forexample,whilewe
createanduseobjectsearly,wedon'thavestudentsdefining

newclassestillfairlylate.Researchincomputingeducation
suggeststhatlearningtoprogramishardandthatstudents
oftenhavetroublewiththebasics(variables,iteration,and
conditionals).Wefocusonthebasicsfortenchapters:three
introductory,fouronpictures,andthreeonsounds.We
introducenewconceptsonlyaftersettingthestageforwhywe
wouldneedthem.Forexample,wedon'tintroduceiteration
untilafterwechangepixelcolorsone-by-one.Wedon't
introduceproceduraldecompositionuntilourmethodsgettoo
longtoeasilybedebugged.
Ourapproachisn'tthemorecommonapproachofintroducing
onecomputingtopicperchapter.Weintroducecomputing
conceptsasneededtodoadesiredmediamanipulation(like
usingnestedloopstomirrorapicture).Somechapters
introduceseveralcomputingconcepts,whileothersrepeat
computingconceptsinadifferentmedium.Werepeatconcepts


indifferentmediatoincreasetheoddsthatstudentswillfindan
explanationandrelevancethatworksforthem,orbetteryet,
findtwoormoreexplanationsthatworkforthem.Thefamous
artificialintelligenceresearcherMarvinMinskyoncesaidthatif
youunderstandsomethinginonlyoneway,youdon't
understanditatall.Repeatingaconceptindifferentrelevant
settingscanbeapowerfulwayofdevelopingflexible
understandings.
Memoryisassociativewerememberthingsbasedonwhatelse
werelatetothosethings.Peoplecanlearnconceptsandskills
onthepromisethatitwillbeusefulsomeday,buttheconcepts
andskillswillberelatedonlytothepromises,nottoeveryday

life.Theresulthasbeendescribedas"brittleknowledge"[7]the
kindofknowledgethatgetsyouthroughtheexambutpromptly
getsforgottenbecauseitdoesn'trelatetoanythingbutbeingin
thatclass.Ifwewantstudentstogaintransferableknowledge
(knowledgethatcanbeappliedinnewsituations),wehaveto
helpthemtorelatetheknowledgetomoregeneralproblems,
sothatthememoriesgetindexedinwaysthatassociatewith
thosekindsofproblems[20].Thus,weteachwithconcrete
experiencesthatstudentscanexploreandrelateto(e.g.,
iterationforremovingred-eyeinpictures).

[Pagexxiv]
Wedoknowthatstartingfromtheabstractionsdoesn'treally
workforstudents.AnnFleuryhasshownthatnovicestudents
justdon'tbuywhatwetellthemaboutencapsulationandreuse
(e.g.,[10]).Studentsprefersimplercodethattheycantrace
easily,andactuallythinkthatcodethatanexpertwouldhateis
better.Someoftheearlymethodsarewrittenthewaythata
beginningstudentwouldprefer,withvalueshardcodedrather
thanpassedinasparameters.Ittakestimeandexperiencefor
studentstorealizethatthereisvalueinwelldesignedsystems.
Withoutexperiencetogivetheabstractionsvalue,it'svery
difficultforbeginningstudentstolearntheabstractions.


Anotherunusualthingaboutthisbookisthatwestartusing
arraysinChapter4,inourfirstsignificantprograms.Typically,
introductorycomputingcoursespusharraysoffuntillater,since
they'reobviouslymorecomplicatedthanvariableswithsimple
values.Butarelevantcontextisverypowerful[17].The

matricesofpixelsinimagesoccurinthestudents'everyday
lifeamagnifyingglassonacomputermonitorortelevision
makesthatclear.
Ourgoalistoteachprogramminginawaythatstudentsfind
relevant,motivating,andsocial.Toberelevantwehavethe
studentswriteprogramstodothingsthatstudentscurrently
usecomputersfor:namely,image,sound,andtext
manipulation.Formotivationweassignopenendedcreative
assignments,suchas:Createanimagecollagewiththesame
imageatleastfourtimesusingthreedifferentimage
manipulationsandamirroring.Asforthesocialaspect,we
encouragecollaborationonassignmentsandonline,public
postingofstudentwork.Studentslearnfromeachotherandtry
tooutdoeachother,inaspiritofcreativecompetition.

WaystoUsethisBook
ThisbookisbasedoncontentthatweteachatGeorgiaTech.
Individualteachersmayskipsomesections(e.g.,thesectionon
additivesynthesis,MIDI,andMP3),butallofthecontenthere
hasbeentestedwithourstudents.
However,wecanimagineusingthismaterialinmanyother
ways:
Ashortintroductiontocomputingcouldbetaughtwithjust
Chapters24.Wehavetaughtevensingledayworkshopson
mediacomputationusingjustthismaterial.


Studentswithsomeprogrammingexperiencecouldskipor
reviewChapters12andbeginatChapter3.Studentswith
objectorientedexperiencecouldstartatChapter4.


[Pagexxv]
Chapter7isaboutdrawingusingexistingJavaclasses.It
alsointroducestheconceptsofinheritanceandinterfaces.
TheconceptsintroducedherearealsousedinChapter14
(movies).Ifyouareskippingmoviesyoucouldskipthis
chapteraswell.
Chapters8through10replicatemuchofthecomputer
sciencebasicsfromChapters4through6,butinthe
contextofsoundsratherthanimages.Wefindthe
replicationusefulsomestudentsseemtorelatebettertothe
conceptsofiterationandconditionalsbetterwhenworking
withonemediumthantheother.Further,itgivesusthe
opportunitytopointoutthatthesamealgorithmcanhave
similareffectsindifferentmedia(e.g.,scalingapictureup
ordownandshiftingasoundhigherorlowerinpitchisthe
samealgorithm).Butitcouldcertainlybeskippedtosave
time.Youmightwanttoatleastcoverclassmethodsand
privatemethodsinChapter10.
Chapter11explainshowtocreateclasses.Thisisan
essentialchapter.
Chapters12and13manipulatetext.Theyalsocover
exceptions,readingandwritingfiles,readingfromthe
network,importstatements,helpermethods,some
collectionclasses,iterators,generics,andworkingwith
databases.Werecommendcoveringthesechapters.
Chapter14(onmovies)introducesnonewprogrammingor


computingconcepts.Whilemotivating,movieprocessing

couldbeskippedfortime.
WedorecommendgettingtoChapter15onspeed.Thisis
thefirstchapterthatismoreaboutcomputingthan
programming.
Chapter16isaboutJavaScript.Thisgivesstudents
exposuretoanotherlanguagethatissimilartoJava.Italso
discussesinterpretersandcompilers.Itcouldbeskippedto
savetime.

[Pagexxv(continued)]

Java
TheprogramminglanguageusedinthisbookisJava.Javaisa
highlevelobjectorientedprogramminglanguagethatrunson
mostcomputersandmanysmallelectronicdevices.Itiswidely
usedinindustryandinuniversities.
ThedevelopmentenvironmentusedinthisbookisDrJava.It
wascreatedatRiceUniversity.Itisfreeandeasytouse.
DrJavaletsthestudentfocusonlearningtoprograminJava
andnotonhowtousethedevelopmentenvironment.An
advantageofDrJavaisthatyoucantryoutJavacodeinthe
interactionspanewithouthavingtowritea"main"method.
Youdon'thavetousethisdevelopmentenvironment.Thereare
manydevelopmentenvironmentsthatareavailableforusewith
Java.Ifyouuseanotherdevelopmentenvironment,justadd
thedirectorythathastheJavaclassesdevelopedforthisbook
totheclasspath.Seethedocumentationforyourdevelopment
environmentforhowtodothis.Ofcourse,youcanalsouse
morethanonedevelopmentenvironment.YoucoulduseDrJava
fortheinteractionspaneaswellasanotherenvironment.



[Pagexxvi]

TypographicalNotations
ExamplesofJavacodelooklikethis:x=x+1;.Longer
exampleslooklikethis:
publicclassGreeter
{
publicstaticvoidmain(String[]args)
{
//showthestring"HelloWorld"ontheconsole
System.out.println("HelloWorld");
}
}

Whenshowingsomethingthattheusertypesintheinteractions
panewithDrJava'sresponse,itwillhaveasimilarfontand
style,buttheuser'stypingwillappearafteraDrJavaprompt
(>):
>3+4
7

UserinterfacecomponentsofDrJavawillbespecifiedusinga
smallcapsfont,likeFilemenuitemandtheCOMPILEALL
button.
Thereareseveralspecialkindsofsidebarsthatyou'llfindinthe
book.

Program1.AnExampleProgram



Programs(recipes)appearlikethis:
publicstaticvoidmain(String[]args)
{
//showthestring"HelloWorld"ontheconsole
System.out.println("HelloWorld");
}


ComputerScienceIdea:AnExampleIdea
Keycomputerscienceconceptsappearlikethis.


×