Questions and Answers for Assignment 2

Wednesday February 26
In your answer to a February 24th question, you said to test each constructor and then move on. Move on to where?

Answer: Move on to testing other methods than the constructors. You only need (at most) two breathers to test the remaining methods.

Wednesday February 26
What is Paradise Chambers in the chamber example?

Answer: This is the address of a chamber. Some addresses are so famous that they don't require street numbers (e.g. Eaton Centre, City Hall).

Wednesday February 26
The instructions for BreatherTester say it should:
prompt the user for information for two
breathers, two chambers, and information for two air fill shops.
	
How can it prompt for an air fill shop or a chamber, aren't these objects (and showInputDialog returns a String)?

Answer: That's information for breathers, chambers, and shops. The information will be provided by the user as one or more Strings. You will also find it more feasible to get the information for the air fill shops first, then the chambers, then the breathers, since this is the order things are most easily built.

Tuesday February 24
Do we need to test every constructor? For example, there are four constructors for Breather, and we're only supposed to create 6 objects, including two chambers and two air fill shops.

Answer: You create a minimum of 6 objects. You should test four constructors, since constructors are methods and you are asked to test every method. You could use each of the four constructors, store the Breather reference in a variable, test that the constructor worked, and move on.

Thursday February 20
You say that we shouldn't worry about the number of decimal places in the number of millilitres per dollar we print. But the example shows the Last Gasp AirFillShop with just 2 decimal places, and I know there's more. Should I round things off to two decimal places?

Answer: No. Here's a more realistic example of what the toString() method for Last Gasp might return:

Last Gasp: 76.92307692307692 millilitres per dollar.
I've modified the A2 handout appropriately.

Thursday February 20
An AirFillShop has a price per litre of air which is never less than $1.00. How can I check that this is so without using an if statement?

Answer: You don't need to check this, just assume that it's so. As a consequence, you don't need to worry about dividing by zero.

Thursday February 20
When the handout says "There are two ways to construct an AirFillShop:" can I choose to implement the method I find easiest?

Answer: No, you must provide the user of your code with the choice! In other words, you implement two different constructors for AirFillShop, two for Chamber, and four for Breather

Monday February 10
There is a discrepancy between the format and the example for the toString method of the Chamber class. Can we assume the colon after (in litres) is required, so that the required format is:
Chamber: address, Air (in litres): xxx, Air fill shop: name. 
	

Answer: Yes. There was a clerical error in the handout, which has now been fixed.


Danny Heap
Last modified: Wed Feb 26 09:00:57 EST 2003