{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Chapter-5

# Chapter-5 - Exercise 1 public class Foo cfw public static...

This preview shows pages 1–6. Sign up to view the full content.

COE318 Fall 2008, Olivia Das, Elec. and Comp. Engg., Ryerson University 1 Exercise 1 public class Foo { public static void main( String[] args ) { int[] anIntArray = {1, 2, 3}; test( anIntArray ); for( int value : anIntArray ) System.out.println( value ); } public static void test( int[] anArray ) { anArray = new int[2]; anArray[0] = 4; anArray[1] = 5; } } Output ??

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
COE318 Fall 2008, Olivia Das, Elec. and Comp. Engg., Ryerson University 2 Exercise 2 public class Person { private String name; public Person( String n ) { name = n; } public String getName() { return name; } public void setName( String n ) { name = n;} public String toString() { return “Name: “ + name; } } mutable ?
COE318 Fall 2008, Olivia Das, Elec. and Comp. Engg., Ryerson University 3 Exercise 2 (continued) public class PersonTest { public static void main(String[] args) { Person p1 = new Person( “Lewis” ); p1.setName( “Loftus” ); System.out.println( p1.toString() ); System.out.println( p1 ); } } Output ?

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
COE318 Fall 2008, Olivia Das, Elec. and Comp. Engg., Ryerson University 4 Example: develop a battleship-style Game: “Sink a Dot Com” user against computer goal: sink all the computer’s DotComs in fewest number of guesses Gives a rating based on how well you perform. No GUI. Command-line version. 0 1 2 3 4 5 6 Pets.com
COE318 Fall 2008, Olivia Das, Elec. and Comp. Engg., Ryerson University 5 First, a high-level design What the game should do ?

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern