Chaper 5 Codes Flashcards
What is the purpose of the SnakeEyes class?
Demonstrates the use of a programmer-defined class
In the SnakeEyes class, how many times are the dice rolled?
500
What are snake eyes in the context of the SnakeEyes class?
Rolling two ones on the dice
What does the Die class represent?
One die with faces showing values between 1 and 6
What is the maximum face value of the Die class?
6
What method in the Die class computes a new face value?
roll()
What does the SloganCounter class demonstrate?
The use of the static modifier
How many Slogan objects were created in the SloganCounter class?
5
What is the purpose of the Slogan class?
Represents a single slogan or motto
What static variable in the Slogan class counts the instances created?
count
What is the output of the SloganCounter class after creating slogans?
Slogans created: 5
What concept does the PigLatin class demonstrate?
Method decomposition
What happens in the PigLatin class when ‘translate another sentence’ is prompted?
It allows the user to translate additional sentences into Pig Latin
What does the PigLatinTranslator class do?
Translates a sentence of words into Pig Latin
What suffix is appended to words in Pig Latin that begin with a vowel?
yay
What method determines if a word begins with a vowel?
beginsWithVowel()
What is the output when translating ‘Do you speak Pig Latin’ into Pig Latin?
oday ouyay eakspay igpay atinlay
What does the ParameterTester class demonstrate?
The effects of passing various types of parameters
What types of parameters are tested in the ParameterTester class?
One primitive and two objects
What is the purpose of the changeValues method in the ParameterModifier class?
Modifies the parameters and prints their values before and after
What happens to the primitive type parameter in the changeValues method?
It does not retain changes after the method call
What happens to the object type parameters in the changeValues method?
They can be modified and retain changes after the method call
What is a key feature of method overloading demonstrated in the Overload class?
Multiple methods with the same name but different parameters
What is the output of the getAverage method for two doubles?
Average of the two double values