COMP1400 – Programming for Designers

Class announcements for Programming for Designers

COMP1400 – Programming for Designers random header image

Wk8 Lab Solutions and Extra Questions

Posted by on September 19th, 2013 · Uncategorized

Here are my solutions to your Week 8 ArrayList and Classes lab. I have added two extension questions. I added comments so that you may follow along with the logic.

I strongly suggest that you try these two questions yourself before checking my solutions. The questions are:

Question 1

Write a method ‘newVIPList’ that takes in an array of strings of VIP member names in the club. The method should take all of the members in the existing club with matching names and return a new array list of members containing only these VIP members.

Question 2

Write a method ‘removeOldMembers’ that takes in a year cut off and removes all the members in the club who joined in a year earlier than the cut off year. This method should not return anything but manipulate the array list field of the club itself.

Please remember these are extension questions that are good practice to test your understanding of ArrayLists and Arrays.

Please Note: I have also included a test method that creates an array of members given a specified size. Feel free to use this and do not worry about the line: String.valueOf(i). It has not been covered in the course thus far and you are not expected to know it.

 

DOWNLOAD FILES HERE:

http://www.cse.unsw.edu.au/~tlen803/infs1609/

No Comments so far ↓

There are no comments yet...Kick things off by filling out the form below.

You must log in to post a comment.