Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is in Java. I can attach a JUnit test if needed. @Test public void testProfile2(){ Profile p = new Profile(John Smith,male); String[] lines =

This is in Java. I can attach a JUnit test if needed.

image text in transcribed

@Test

public void testProfile2(){

Profile p = new Profile("John Smith","male");

String[] lines = {"http://www.cs.gmu.edu/~kdobolyi/headshot.jpg 223"};

String exceptionType = "NONE";

try{

p.parseDataDump(lines);

}catch (Exception e){

exceptionType = e.getClass().toString();

}

assertEquals(223, ((Photo)p.getPhotos()[0]).getSize());

assertEquals("http://www.cs.gmu.edu/~kdobolyi/headshot.jpg", ((Photo)p.getPhotos()[0]).getLocation());

assertEquals("headshot.jpg", ((Photo)p.getPhotos()[0]).getName());

assertEquals(1,p.getPhotos().length);

assertEquals("NONE",exceptionType);

assertNotEquals(0,++passed);

}

@Test

public void testProfile3(){

Profile p = new Profile("John Smith","male");

String[] lines = {"http://www.cs.gmu.edu/~kdobolyi/headshot.jpg223"};

String exceptionType = "NONE";

try{

p.parseDataDump(lines);

}catch (Exception e){

exceptionType = e.getClass().toString();

}

assertNotEquals("NONE",exceptionType);

assertNotEquals(0,++passed);

}

@Test

public void testProfile4(){

Profile p = new Profile("John Smith","male");

String[] lines = {"CONTACT Jane Doe"};

String exceptionType = "NONE";

try{

p.parseDataDump(lines);

}catch (Exception e){

exceptionType = e.getClass().toString();

}

assertEquals("Jane Doe", ((String)p.getContacts()[0]));

assertEquals("NONE",exceptionType);

assertNotEquals(0,++passed);

}

@Test

public void testProfile5(){

Profile p = new Profile("John Smith","male");

String[] lines = {"POST#12/23/15#my message#http://www.cs.gmu.edu/~kdobolyi/headshot.jpg 223"};

String exceptionType = "NONE";

try{

p.parseDataDump(lines);

}catch (Exception e){

exceptionType = e.getClass().toString();

}

assertEquals("NONE",exceptionType);

assertEquals("12/23/15", ((Post)p.getPosts()[0]).getDate());

assertEquals("my message", ((Post)p.getPosts()[0]).getText());

assertEquals("http://www.cs.gmu.edu/~kdobolyi/headshot.jpg", ((Post)p.getPosts()[0]).getPhoto().getLocation());

assertEquals("http://www.cs.gmu.edu/~kdobolyi/headshot.jpg", ((Photo)p.getPhotos()[0]).getLocation());

assertNotEquals(0,++passed);

}

@Test

public void testProfile6(){

Profile p = new Profile("John Smith","male");

String[] lines = {"POST 12/23/15 my message http://www.cs.gmu.edu/~kdobolyi/headshot.jpg 223"};

String exceptionType = "NONE";

try{

p.parseDataDump(lines);

}catch (Exception e){

exceptionType = e.getClass().toString();

}

assertNotEquals("NONE",exceptionType);

assertNotEquals(0,++passed);

}

elass Profile Tho parpose of this cla is to model a or's grofle o aur social netwarking sito ATTRIDUTES(please do nat change theiraro) objeat pbotos objeat[1 contaots objeat[ posts objeat[ essages Striag usernane Striag gender METHODS please do not change theiz ames) publie Profile(string usernane, String Th array will sere Dhoto o ]ccts. Warning! h's pree acucat to use primita e arrays, which re ta e ????ze, t erof p o as. Similarly, by haviag du pe afthc array bo ab eet, we vill un a tanately at po at ally usu ely have tn cat back to anc t cee Bro ang man the Photo type each time ve want o access and use a stored photo. These inefficiencies will exist in the three oher attribetes below as we This array will store String objects which are the names of contacts This array will storePost objects This array will sMessage chjects, This wall stooe the usemame of the person who holds the proile This wall stooe the pender o the pervon who holds the profile geader) gettersisetlers for all the attributes above public void parseDataDump (object[l This constrctorill set the actributes to the incoming arguments. Use the Source optioa to auomacically geperate these in Eclipse. nis method t es an array o data, and prses the elements as str gs k try to build a profile rom t e data. t will Ese all four o he metods eloi to try to match one of those elemenx ?al ne in the incomang ngument doesn't match any of tose our types, this method will lines) (which sa elass you wal ereate, described lelam). Th 5 oth d is used by Paroo atapunpyod k ifa is a Photo er n s if it is de inefficient dDa gerou a dd b eet i be called below ton dd a g y c sa od Photo by t to thi pot e (his?t d is detaalod below). A line is a pho if it contains the string.becaase photos are stored at a location (sch as a URI or folder). Such a line wall start with this locatia of the photo, follooved by a sace,followed by the size of che photo. The name of a photo will he the sringoocuring ter the This method is ed by parse atap n??d k ifa n is a contact er noe if it is, de ineffielentAndDangerouaaddob ees ill bc called belo to add a D conta ct {a s ring) to 8 prodle (this m thod is eta d beige). Alme ?sa contact if it starts with the striaE CONTACT followed by a?ace.i lowed by the fint and last nare of anoher user (oranned by another space This method is used by parseDataDunp o check if s line is & Post or nor if it is, the inetti A line is & p at it starts with h snag POS? ENowed by 1followed by the da , followed by a R, & owed by the let ufa past. On hine, a Post stay bc associated wi Plxto ? well, dc cod; b th dic ptal and the hoa, slauld be added to tle prle. This method is used by parooDataDump tocheck ifalino is aMossago or oot, if it is, tho inoffici A line isa message if it surs with che nng NESSA 8. follo ed by a followed by ? contact. kilo ed by a followed by te date, follo ed by a followed by the text of a post. Bot the post and the coata t should be added to the pr tile. This method useste instanceof key ond on the ncoming o con oc de mine its type and adds it to te conect amay. War im T his is an ine licient and dangerous ?y to add ob ects lo heir re ective arrays Think a out how you'd want to rewrite this for private boolean peivate booleas nineCoetace (string lian) ect will be eslled below to add a new post tothis profile (this methed is detsiled below). private boolean nineFost (String 1ine) ntAndDangorouAddobioct will be called below to add a sow post so this peofile (this method is decailed below) private booleas ninetessage(String liae) public void ineffieientADaagereuanddobject (Objeet objeat) your asecsement. Rea that arrays n Java aEg fixed in Sice, Obch tim. Dow ? an ?s a od to the un y, ?l East gro aceutenta y by one unit (otsi aas,auremely ingeeicat aak .boat bo you oould in covo this . a or your asseomon Ia this method, make sure not to store dplicate photos elass Profile Tho parpose of this cla is to model a or's grofle o aur social netwarking sito ATTRIDUTES(please do nat change theiraro) objeat pbotos objeat[1 contaots objeat[ posts objeat[ essages Striag usernane Striag gender METHODS please do not change theiz ames) publie Profile(string usernane, String Th array will sere Dhoto o ]ccts. Warning! h's pree acucat to use primita e arrays, which re ta e ????ze, t erof p o as. Similarly, by haviag du pe afthc array bo ab eet, we vill un a tanately at po at ally usu ely have tn cat back to anc t cee Bro ang man the Photo type each time ve want o access and use a stored photo. These inefficiencies will exist in the three oher attribetes below as we This array will store String objects which are the names of contacts This array will storePost objects This array will sMessage chjects, This wall stooe the usemame of the person who holds the proile This wall stooe the pender o the pervon who holds the profile geader) gettersisetlers for all the attributes above public void parseDataDump (object[l This constrctorill set the actributes to the incoming arguments. Use the Source optioa to auomacically geperate these in Eclipse. nis method t es an array o data, and prses the elements as str gs k try to build a profile rom t e data. t will Ese all four o he metods eloi to try to match one of those elemenx ?al ne in the incomang ngument doesn't match any of tose our types, this method will lines) (which sa elass you wal ereate, described lelam). Th 5 oth d is used by Paroo atapunpyod k ifa is a Photo er n s if it is de inefficient dDa gerou a dd b eet i be called below ton dd a g y c sa od Photo by t to thi pot e (his?t d is detaalod below). A line is a pho if it contains the string.becaase photos are stored at a location (sch as a URI or folder). Such a line wall start with this locatia of the photo, follooved by a sace,followed by the size of che photo. The name of a photo will he the sringoocuring ter the This method is ed by parse atap n??d k ifa n is a contact er noe if it is, de ineffielentAndDangerouaaddob ees ill bc called belo to add a D conta ct {a s ring) to 8 prodle (this m thod is eta d beige). Alme ?sa contact if it starts with the striaE CONTACT followed by a?ace.i lowed by the fint and last nare of anoher user (oranned by another space This method is used by parseDataDunp o check if s line is & Post or nor if it is, the inetti A line is & p at it starts with h snag POS? ENowed by 1followed by the da , followed by a R, & owed by the let ufa past. On hine, a Post stay bc associated wi Plxto ? well, dc cod; b th dic ptal and the hoa, slauld be added to tle prle. This method is used by parooDataDump tocheck ifalino is aMossago or oot, if it is, tho inoffici A line isa message if it surs with che nng NESSA 8. follo ed by a followed by ? contact. kilo ed by a followed by te date, follo ed by a followed by the text of a post. Bot the post and the coata t should be added to the pr tile. This method useste instanceof key ond on the ncoming o con oc de mine its type and adds it to te conect amay. War im T his is an ine licient and dangerous ?y to add ob ects lo heir re ective arrays Think a out how you'd want to rewrite this for private boolean peivate booleas nineCoetace (string lian) ect will be eslled below to add a new post tothis profile (this methed is detsiled below). private boolean nineFost (String 1ine) ntAndDangorouAddobioct will be called below to add a sow post so this peofile (this method is decailed below) private booleas ninetessage(String liae) public void ineffieientADaagereuanddobject (Objeet objeat) your asecsement. Rea that arrays n Java aEg fixed in Sice, Obch tim. Dow ? an ?s a od to the un y, ?l East gro aceutenta y by one unit (otsi aas,auremely ingeeicat aak .boat bo you oould in covo this . a or your asseomon Ia this method, make sure not to store dplicate photos

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle9i Database Administrator Implementation And Administration

Authors: Carol McCullough-Dieter

1st Edition

0619159006, 978-0619159009

More Books

Students also viewed these Databases questions

Question

Explain the market segmentation.

Answered: 1 week ago

Question

Mention the bases on which consumer market can be segmented.

Answered: 1 week ago