Page 371 - Introduction to Programming with Java: A Problem Solving Approach
P. 371
e) It minimizes overall cost. (T / F)
f) It results in the fewest number of undetected bugs. (T / F)
16. In a top-down design process, which do you decide on first—the classes or the public methods?
§8.7 Bottom-Up Design
17. When should you use bottom-up design?
§8.9 Iterative Enhancement
18. If a prototype is successful, what temptation should you resist?
19. Once you select a particular design methodology, keep using that same methodology throughout the entire
design process, and do not allow other methodologies to “contaminate” the process originally selected. (T / F)
§8.10 Merging Driver Method into Driven Class
20. You can drive any class from a main method within that class, and you can retain that main method for
future testing of that class even though that class is normally driven from another class in a larger program. (T / F)
Exercises
1. [after §8.2] Describe the way to declare variables that conforms to good style. Include description of when and how to include associated comments.
Apago PDF Enhancer
2. [after §8.2] Correct the style of the following class definition.
/*Environment.java This class models the world's environment.
It was written by Dean & Dean and it compiles so it must be OK*/
public class Environment{//instance variables
private double sustainableProduction;private double
initialResources;private double currentResources;private
double yieldFactor = 2.0;public void setSustainableProduction
(double production){this.sustainableProduction = production;}
// Set pre-industrial mineral and fossil resources
public void setInitialResources(double resources){this.
initialResources=resources;}
// Initialize remaining mineral and fossil resources
public void setCurrentResources(double resources){this.
currentResources = resources;}
// Fetch remaining mineral and fossil resources
public double getCurrentResources(){return this.
currentResources;}/*Compute annual combination of renewable
and non-renewable environmental production*/public double
produce(double populationFraction,double extractionExpense){
double extraction;extraction=this.yieldFactor*
extractionExpense*(this.currentResources/this.
initialResources);this.currentResources-= extraction;return
extraction+populationFraction*this.sustainableProduction;}}
3. [after §8.3] Given the following shirt-design program, which is the same as the Shirt program in Figures 8.3 and 8.4, except for a slight modification in main:
Exercises 337