========================= QUICK DEMO: homework 6 ----- v1: fill in the blanks - IVs, names, static ----- v2: canvas, tester ========================= FIXING SOLUTION TO EXERCISE: the split > Student s = new Student( "810061 04,SCHAFER,J,BEN,123456,schafer@cs.uni.edu" ); > s.emailDomain() "uni.edu" > Student t = new Student( "810061 04,GUY,MADE,UP,234567,indecipherable.mess@gmail.com" ); > t.emailDomain() "mess@gmail.com" ----- fix: split at @ first! String[] emailComponents = emailAddress.split( "@" ); String domain = emailComponents[1]; > Student s = new Student( "810061 04,SCHAFER,J,BEN,123456,schafer@cs.uni.edu" ); > s.emailDomain() "uni.edu" > Student t = new Student( "810061 04,GUY,MADE,UP,234567,indecipherable.mess@gmail.com" ); > t.emailDomain() "gmail.com" ========================= TASK: read lines from a CSV file into set of object > StudentReader reader = new StudentReader( FileChooser.getMediaPath("ew/ClassList.csv") ); > Student[] csOne = reader.getRoster(); > csOne[0] ID: > csOne[1] ID: ========================= TASK: fix problems -- too [few|many] slots > csOne.length 50 > csOne[49] null > csOne[29] null > csOne[24] null > csOne[23] ID: ----- 1 add a guard, then break ----- 2 trim the array > StudentReader reader = new StudentReader( FileChooser.getMediaPath("ew/ClassList.csv") ); > Student[] csOne = reader.getRoster(); > csOne.length 24 > csOne[23] ID: > csOne[24] ArrayIndexOutOfBoundsException: at java.lang.reflect.Array.get(Native Method) ----- see slide for a "template" ========================= EXERCISE: read e-mail addresses from prospects file mac os x > cd ~/home/teaching/cs1/sessions/session24/ew/ mac os x > ll total 112 -rw-r--r-- 1 wallingf wallingf 1293 Nov 16 11:32 ClassList.csv -rw-r--r-- 1 wallingf wallingf 44999 Nov 21 09:12 prospects-101806.csv mac os x > wc ^C mac os x > wc prospects-101806.csv 218 2290 44999 prospects-101806.csv > String filename = FileChooser.getMediaPath( "ew/prospects-101806.csv" ); > ProspectReader reader = new ProspectReader( filename, 218 ); > String[] addresses = reader.getAddresses(); > addresses[137] "" > addresses[138] ""someusername@hotmail.com"" > addresses[138].charAt(0) '"' > addresses[138].charAt(1) 's' ----- QUICK: how to trim inner ""? > String filename = FileChooser.getMediaPath( "ew/prospects-101806.csv" ); > ProspectReader reader = new ProspectReader( filename, 218 ); > String[] addresses = reader.getAddresses() > addresses[137] "" > addresses[138] "someusername@hotmail.com" > addresses[138].charAt(0) 's' > addresses[138].charAt(1) 'o' ========================= EXERCISE: how many hotmail addresses? > String filename = FileChooser.getMediaPath( "ew/prospects-101806.csv" ); > ProspectReader reader = new ProspectReader( filename, 218 ); > reader.numberOfAddressesAt( "gmail.com" ) 4 > reader.numberOfAddressesAt( "hotmail.com" ) 35 > reader.numberOfAddressesAt( "yahoo.com" ) 14 ========================= TASK: read a Picture from the web! > FoxTrotDownloader app = new FoxTrotDownloader(); > //Picture p =// app.getTodaysCartoon(); //> p.show();//