Message in a bottle Download

Christina Cacioppo

classes, visibility, arraylists Polish needed


Introduction

You know in movies or books, when somone finds a bottle that's been flung out to sea with a message inside? Let's build that.


Task

Here's the basic outline of what we'll build:

  1. A Bottle class, which'll be public.
    1. A bottle has one attribute, a String message, that's added to the bottle when it's constructed.
    2. Bottles also have a void scramble() method that, when called, scrambles the letters in the message however you like. The scrambler should maintain all the letters in the message; they should be in a different order but all there. The scrambler should also work no matter what the bottle's message is – including when the bottle doesn't have a message.
  2. An Ocean class that has one attribute: a private array of Bottles.
    1. Constructing a new Ocean should initilize the array.
    2. A public Bottle retreiveOne() method that pulls a bottle out of the ocean at random and prints its message.
    3. A public void throw(Bottle b) that adds the Bottle b to the array of bottles in the ocean.


Starter code

class Bottle{
	
}

class Ocean{
	
}


Useful tools to solve the problem