HW1 2 - unique, int capacity) This should constuct a list...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
switch off, then adding three occurrences of the number 42 will generate the list 142,42, 421. Adding those same three occurences of 42 to an empty list that has the unique switch on will generate the list [42]. This extra piece of state will require the addition of several new methods. Your class should keep the DEFAUR_CAPACITY constant and should have a total of four constructors: Your class should include the following two new methods: The setUnique method presents a potential problem for us. Suppose that the client has constructed a list and has added many values, including duplicates. If the client then tries to set unique to true, this is supposed to prevent duplicates. But the duplicates are already there. In this case, the setUnique method should remove the duplicates and should guarantee that no additional duplicates are added unless the client changes the setting back to false. If the client changes the setting back to false, that will mean that duplicates Method Description
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: unique, int capacity) This should constuct a list tvith given capacity and with the given setting for whether or not to limit the list to unique values (tue means no duplicates, false means duplicates are allowed) Sortedlntl-ist(int capacity) This should construct a list with the given capacity and with unique set to false (duplicates allowed) Sortedlntlist(boolean unique) This should construct a list of default capacity with the given setting for unique (true means no duplicates, false means duplicates are aiioweci) Sortedlntl,ist$ This should construct a list of default capacity with unique set to false (duplicates allowed) Method Description boolean getUnique0 This method should return the current setting for unique (tue means no duplicates, false means duplicates are allowcd) void setUnique(boolean value) This method allows the client to set whether or not to allow duplicates (true means no duplicates, false means duplicates allowed) Page2 of4...
View Full Document

This note was uploaded on 11/03/2009 for the course CSE 143 taught by Professor Sr during the Spring '08 term at University of Washington.

Ask a homework question - tutors are online