I am currently working on the following questions as revision:
A VolumeModel stores the data for a volume control object. The volume has level and it can also be put in a muted state.
(The following underneath is what is drawn in a UML diagram:)
VolumeModel - The Class name
muted: int - The attribute
level: int - The attribute
+..methods.. - The methods for the class
a) Write down all the method headers, including the constructors, that you would expect to see in this class so that it conforms with conventional standards supporting data encapsulation. (Do not write the method bodies or documentation).
As my answer for that question I wrote it as this:
public VolumeModel()
public VolumeModel(boolean muted, int level)
public void setLevel(int level)
public int getLevel()
public setMuted(boolean muted)
public boolean isMuted()
public void turnUp()
public void turnUp(int level)
public String toString()
public boolean equals(VolumeModel V)
I do not know if that is ALL the expected method headers, including the constructors, that is expected to be seen in this class because of the following question (that is related to the above question) underneath:
b) Using the method you declared in part (a), write the code for a test program to:
- create an instance of a volume model...
- with a volume level 1 and not muted:
- in a loop, steadily increase the volume to level 10:
- then mute the volume;
- finally output the state of the volume model object
As my answer to that question above so far, I have done this:
VolumeModel vml = new VolumeModel();
vml.setLevel(1);
vml.setMuted(false);
VolumeModel volumelevel = new VolumeModel(true, 11);
while (!vml.equals(volumelevel)
{
//to be completed
}
That piece of code above is not finished as I am struggling on that, so if there are any tips that someone could give me then I would appreciate it.
Also, any suggestions and feedback on my following answer of question a) would also be of help.
Thanks in advance.
p.s - I am unable to try this code out on my eclipse software because my eclipse software is not working on my laptop for some reason, however when I find time to go to my computer labs then I will see if I can test the code on the eclipse software on their computers over there.