At first I only had a class for the market and a class for a fisherman. I've now decided to add a class for weather and a class for fish.
The weather class constructor is not going to take any arguments. All the class needs is a field for a random number generator. The constructor can allocate the Random object. I'll also make a method that can be called to get the weather. It can use the Random object to get one of four possible values and return one of the weather strings. Each fisherman is supposed to check the weather, so I'll add that to my fisherman class. Every time something calls the getWeather method, a new random number will be generated and the weather will change.
I'll call the class that will contain the main SaltyFishMarket. Here's my plan for that class. My main will be ultra-simple:
public static void main(String[] args)
{
SaltyFishMarket sfm = new SaltyFishMarket();
}
Originally my main was really long. To make it short like that, I'm going to take all the variables I had in main and make them be fields of this class. The work that my original main was doing could be divided up as follows:
- set up the decimal format and scanner stuff
- buy fish from three fishermen
- figure out the price to charge
- sell fish to some customers
I'll have the constructor set things up. After it does that, it will call some other methods. I'll make a buyFish and a setPrice and a sellFish method that the constructor can call.
Okay, I'll get to work on this and will post again when I've made some progress.
No comments:
Post a Comment