Question: Type and compile listing 9.3, page 329 (file TV.java). Notice that this is a class with no main method, you cannot run it. 2. Now,
Type and compile listing 9.3, page 329 (file TV.java). Notice that this is a class with no main method, you cannot run it.
2. Now, type, compile, and run listing 9.4, page 330 (file TestTV.java). Next, make some changes to this class to create another object, say tv3. Invoke all methods of class TV on this new object in the logical order and print out a meaningful message after each method call indicating the change to the object. (This is known as testing the class methods on an object).


volumeLevel: int on: boolean The + sign indicates public modifier +turnon() void +turnoff ): void +setChannel (newChannel: int): void +setVolume (newVolumeLevel: int): void +channe1Up(): void +channe1 Down (): void +volumeUp(): void +volumeDown (): void FIGURE 9.6 The TV class models TV sets. Listing 9.3 gives a program that defines the TV class. LISTING 9.3 TV.java 1 public class TV f int channel = 1; // Default channel is 1 int volumeLevel = 1; // Default volume level is 1 4 boolean on = false; // TV is off 6 public TV) f 8 9 public void turnon() ( 10 on = true; 12 13 public void turnoff()
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
