473,322 Members | 1,405 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Shared members, Events, Collections problem?

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 Lights?
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.


--
- W.
Mar 23 '07 #1
2 1863
Wujood <Wu****@discussions.microsoft.comwrote:
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 Lights?
Any help in terms of pseudo code or implementation would be appreciated.
I don't see any requirement which would involve hashtables or events.
Not sure what you mean by "shared members".

I'd make the scene have a list of lights, but exactly what form that
would take depends on whether you're using .NET 1.1 or 2.0.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Mar 23 '07 #2
OK, I figured it out and it works. I realized the many to many relationship
between Light and Scene. So I use ArrayList for each in these two classes. I
know this could be made elegant using Generics in 2.0 but for the sake of
simplicity I use ArrayLists.

Thanks All.

"Jon Skeet [C# MVP]" wrote:
Wujood <Wu****@discussions.microsoft.comwrote:
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 Lights?
Any help in terms of pseudo code or implementation would be appreciated.

I don't see any requirement which would involve hashtables or events.
Not sure what you mean by "shared members".

I'd make the scene have a list of lights, but exactly what form that
would take depends on whether you're using .NET 1.1 or 2.0.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Mar 23 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: John Brock | last post by:
I have a base class with several derived classes (I'm writing in VB.NET). I want each derived class to have a unique class ID (a String), and I want the derived classes to inherit from the base...
1
by: Iulian Ionescu | last post by:
I have the following problem. I derived a class from ArrayList to provide some additional events I need. Then I derived 2 different classes from this one and each of them defines an indexer that...
3
by: Sasha | last post by:
Hi everyone, Here is my problem: I have the following classes: - DataNode - this class is designed to hold some data and will be contained in a tree like data structure DataTree. When...
3
by: Ryan Steckler | last post by:
I found this behavior while trying to implement a singleton class. Below is a somewhat more straight forward example, though admittedly less useful in real life. The basic problem is that when a...
11
by: dee | last post by:
OleDbCommand class like many .NET classes has the following description in its help file: "Thread Safety Any public static (Shared in Visual Basic) members of this type are safe for...
6
by: Daniel Fernandes | last post by:
Hi there Is there any difference I need to be aware when I create a class with only shared members & procedures when compared to a module (which is a shared class) ? I am asking this because...
4
by: Rubbrecht Philippe | last post by:
Hi there, I would like to develop an interface that when implemented in a class requires a number of shared properties or methods to be available. It seems a Shared Member can not be used as...
5
by: Simon | last post by:
Hi all, We have an ASP.NET 1.1 application running on IIS6 on Server 2003. Most of the base objects we are using in this application are taken from a windows application also written by us. We...
2
by: =?Utf-8?B?V3Vqb29k?= | last post by:
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.