flâneur — a map of the web's best reading

CS 106A – Ed Discussion

edstem.org · 6 words · saved by 1 readers

Please read this problem and try it yourself before class tomorrow. In addition to the midterm retro, we will discuss this problem as well. This is probably as hard as I'll make the final exam problem on classes (ie, the actual exam problem should be easier) Adapted from a problem by Julie Zelinski The RandomBag class models a collection of names with an operation for random selection, such as might be used for a lottery. The bag capacity is set in the constructor. The add operation adds a name to the bag. The choose operation selects a name from the bag at random and removes it. Here is the interface of the class: You are to write the complete RandomBag class, including implementation of the constructor and member functions. Design: A RandomBag holds a collection of names. The required internal representation is a list of strings (this means, you constructor should initialize a list to hold the names). The names in the list are in no particular order. Your design can include other ins

Ed Discussion Skip to main content

Explore this link on the map →

related reading