Shared members, Collections, Events Problem?

G

Guest

I am trying to solve the following take home assignment problem. I am not
sure whether to use Hashtables, events and shared members or could it be done
more easily? Also, do I need to implement a Generic Collection for Light
class? Any help in terms of pseudo code or implementation would be
appreciated.

----------------

Define a set of classes and methods to model these entities:
- a Light that you can turn on and off
- a Light that you can turn on and off and also set to a specific light
level e.g. 50% brightness.
- a Scene which contains a number of Lights, with a level specified for each
Light
o a Scene can be turned on or off
o Lights can be in multiple Scenes
o A Light is only turned off if all Scenes that it is part of are off

In our scenario we have 2 Scenes (A and B).
Scene A
- Lights 1 (on), 2 (on), and 3 (50%).

Scene B
- Lights 3 (70%), 4 (on), and 5 (on)

Write some client code that will create the objects to model our 2 Scenes,
turn on both scenes, then turn off Scene B. Please show the implementation
that will allow Light 3 to stay on after Scene B is turned off.
 
G

Guest

by the way im understanding it, you could just create a Light object that has
a property On (boolean) and brightness (integer 0-100). Then create a Scene
class that has a list of all lights inside of it (plus an on or off
property). hopefully this gives u a slight push in the right direction
 
G

Guest

Well, so far I have following:

public class Light
{
private string lightId;
private ArrayList scenes;
private bool lightState;

public Light()
{
//init values here
}

//some properties and methods
}
....Then I also have a derived class >>> public class AdjustableLight : Light
...... that has a property to set the light level.

public class Scene
{
private string sceneId;
private bool sceneState; //true = ON, false = OFF
private ArrayList lights;

public Scene(string id)
{
sceneId = id;
sceneState = false;
lights = new ArrayList( );
}

//Some methods and props here

}

The problem is how to make sure Light 3 stays ON after Scene B is turned
off? Do I also need to use events here??
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top