Programming Fundamentals IT 108
Popular in Course
Popular in Information technology
This 4 page Class Notes was uploaded by Adonis Nader on Monday September 28, 2015. The Class Notes belongs to IT 108 at George Mason University taught by Irene Bruno in Fall. Since its upload, it has received 46 views. For similar materials see /class/215221/it-108-george-mason-university in Information technology at George Mason University.
Reviews for Programming Fundamentals
Report this Material
What is Karma?
Karma is the currency of StudySoup.
Date Created: 09/28/15
T108 April 30 2009 On Blackboard 0 Two new links 0 What the final is going to be link 0 Questions from past exams she did not use any of them this year Tuesday 0 Anything you want to do Tuesday we will do 0 I will stare at you until you ask me questions Phase Two Information 0 User should be able to choose 0 API documentations o Char class 0 String class I Don39t have to include all the crap 0 Just need to include name data types etc You need to know which methods to play around with before the Final 0 Background information 0 These are the common ones 0 Once you get use to them you will be able to use them 0 The last sheet of the final provided will be API stuff that you don39t need to include on your cheat sheet 0 The two methods 0 Differences between Character and String I Char 0 Does not deal with instance variable I Str 0 Does stuff with instance variable I 0 Character I Provides us to have methods I Methods Bruno is interested in isDigit isSpqce isLetterOrDigit Aquot did Aquot of lsLetter them isUpperCa se I isLowe rCase 0 String I Method types 0 charAt 0 equals 0 equalgnoreCase length All Instance All of Illeln comparer0 Notice the lack of static Does stuff with instance variable T108 April 30 2009 indewaf Substring toUppercase o toLowerCase I remember a string is an object I String name 6 creates reference variable I Every time double quotes are used a new string is called name quotBobquot name newStringC39Bobquot 0 Such as o characterAt o Equals I String are immutable 0 Never really change 0 Really another one is created and the other is sent out for trash Example Code may help with phase two hint hint Don39t expect copy and paste will worhl GMU leer 0 Play around with this code 0 Validation rules 0 No spaces 0 Between 5 and 20 characters T108 April 30 2009 o Atleast one digit 0 Gnumber I First character capital G I Must be eight digits Code Go to API and find what you need charAt in this case Do not need an import statement public class user private String id private String sethum public boolean setuser String u If you have double quotes it will not work39 Go to API and find what you need Length in this case ifgcharAtO 0 return false ifglength O 9 1 return false For EACH forlnt I 1 lt 9 I characterl need ifcharacterisDigit gcharAti to figure out if q digit If not get ifIIZCharacteszE39i39 itvghrrrcxMUD Wt class acces each char ratic Better to ask Public boolean setuserString u what doesn t fit Then kick ifvalidu them ut d return false Go to Am I 39 139 and find return true what you need Private boolean validString user Length in this case ifuserlength lt 5 ll userlength gt 20 Go to API and find what you need indexOf in this case I want you take this string and see where a space is and return positive numberquot If nothing then it will return a negative number Negative get out return false ifuserindex0f 39 gt 0 return false forint i O ilt userlengfl i ifCI1cn acterisDigituserchcrrAti return true return false T108 Import javaxswing JOptionPane Public class Email April 30 2009 edu Ask for an email and if Public static voiod main String args String email Go to API and find what you need substring in this case user oneUser new User 0 do email JOptionPaneShowlnputDialogC What is your Emailquot ifemailsubstringemaillength 3 equalslgnoreCase EDUquot Ls L2 L 1 ibrunoiagmu iFCemoilsubstring emaiLengthC a equalslgnoreCaseC EDU j stringobject ifemailsubstringemailindexOf 1 emailindexOf emailindexOf 1 equalslngoreCase GMUquot Start at position one until the position right before the a sign Fix it up Import javaxswing JOptionPane Public class Email Let s play String Public static voiod main String args String email user oneUser new User 0 do email JOptionPaneShowlnputDialogC What is your Emailquot email emaitoLowercase whileloneusersetUseremailsubstringO emailindexOf 1 ifemailsubstringemaillength 3 email emaitoLowercase eduquot ifemailsubstringemailindexOf 1 emailindexOf emailindexOf 1 equals GMUquot whileloneusersetUseremailsubstringO emailindexOf 1 name1 Bob name2 Andy name3 Bob