Hey everyone,
Quick Question Posed to ME
----------------------------------------------------------------------------------------------------------------------
The question:
Create a Television store that can hold three Television objects in an
array. Use the Television class below:
class Television
{
boolean isOn;
} // end class Television
Use a for loop to print the isOn instance variable for each Television in the
TelevisionStore. Use a second for loop to change the isOn instance variable for
each Television to “true”. Finally, use a third for loop to print the isOn instance
variable for each Television in the TelevisionStore array.
Sample output:
Openening the tv store for the day... tv status:
Television 0 is on? False.
Television 1 is on? False.
Television 2 is on? False.
Turning the tv's on...
Television 0 is on? True.
Television 1 is on? True.
Television 2 is on? True.
----------------------------------------------------------------------------------------------------------------------
So I made a program that does create this output, with this code + the Television Class I was supposed to create:
public class TelevisionDriver { public static void main( String[] args ) { String[] Television = { "Television 0", "Television 1", "Television 2", "Television 0", "Television 1", "Television 2" }; String[] Boolean = { "False", "False", "False", "True", "True", "True"}; System.out.println( "Openening the tv store for the day... tv status:"); for( int x = 0; x < 3; x++ ) { System.out.println( Television[x] + " is on? " + Boolean[x] + "." ); } System.out.println( "\n" + "Turning the tv's on..." ); for( int y = 3; y < 6; y++) { System.out.println( Television[y] + " is on? " + Boolean[y] + "." ); } } }
----------------------------------------------------------------------------------------------------------------------
Is this the proper way to do it? I think I was supposed to do something different, even though the output is correct.