Click here to Skip to main content
16,005,236 members
Home / Discussions / C#
   

C#

 
AnswerRe: How to close the window using its Window Handle. Pin
stancrm4-Mar-07 22:06
stancrm4-Mar-07 22:06 
GeneralRe: How to close the window using its Window Handle. Pin
engsrini4-Mar-07 22:32
engsrini4-Mar-07 22:32 
Questionhow to update changes in SQL database using DataAdapter Pin
niting854-Mar-07 19:22
niting854-Mar-07 19:22 
AnswerRe: how to update changes in SQL database using DataAdapter Pin
Colin Angus Mackay4-Mar-07 20:45
Colin Angus Mackay4-Mar-07 20:45 
AnswerRe: how to update changes in SQL database using DataAdapter Pin
Luka Grabarevic5-Mar-07 0:06
Luka Grabarevic5-Mar-07 0:06 
Questionadd virtual column Pin
waleed994-Mar-07 18:24
waleed994-Mar-07 18:24 
AnswerRe: add virtual column Pin
saeee4-Mar-07 19:59
saeee4-Mar-07 19:59 
QuestionAn elevator Problem Pin
ebey4-Mar-07 18:18
ebey4-Mar-07 18:18 
You are given a console program in both VB and C# that uses a class CElevator
(ElevatorAppAssign).
The main modules are in the assign directory class files.
Below is a discussion of that for VB; the one for C# is similar.
This discussion will show what is needed to write the class CElevator (in both VB and
C#).
When this class is complete, add it to your projects, and then run the projects.
Hand in the code for CElevator and the output (one set for VB, one set for C#).
An explanation of the application code follows
The main module starts with:
Sub Main()
Dim anElevator As CElevator = New CElevator(0, 10, 8)
The class CElevation should have only one constructor that takes three parameters:
(1) lowest floor number
(2) highest floor number
(3) maximum number of passengers that can be on the elevator
anElevator.Status()
The method Status should output to the screen text with the following format:
The elevator is at floor XX, with YY persons
Console.WriteLine("At floor {0}", anElevator.Floor)
Console.WriteLine("Number of persons in elevator is {0}", _
anElevator.Occupants)
Console.WriteLine()
The property Floor should return the floor number the elevator is on, an integer.
The property Occupants should return the number of persons on the elevator.
The above two properties should not be capable of setting these values; only returning
them.
anElevator.Enter(3)
anElevator.Enter(2)
anElevator.Leave(1)
Console.WriteLine("Number of persons in elevator is {0}", _
anElevator.Occupants)
Console.WriteLine()
The method Enter(noPass) tries to place noPass additional passengers on the elevator.
The method Leave(noPass) tries to remove noPass passengers from the elevator.
These methods must guard against having above the maximum number of passengers on
the elevator, or less than 0 passengers on the elevator.
The Enter method should allow as many passengers as possible to enter the elevator.
In particular, if the elevator is full, print the console message:
"Elevator full, so no one entered"
If there are more people trying to enter the elevator than space permits, allow whatever
number can enter, and print the console message:
"Only allowed XX persons to enter"
If there is room for everyone to enter, no message should be printed.
Similarly, the Leave method: should allow as many passengers as possible to leave the
elevator.
In particular, if the elevator is empty, print the console message:
"Elevator empty, so no one left"
If there are more people trying to leave the elevator than are on the elevator, allow all the
passengers to leave, and print the console message:
"Only have XX number of persons leaving"
If there is room for everyone to leave, no message should be printed.
anElevator.GoToFloor(3)
anElevator.GoDownOneFloor()
anElevator.GoDownOneFloor()
anElevator.GoUpOneFloor()
Console.WriteLine("At floor {0}", anElevator.Floor)
Console.WriteLine()
The method GoToFloor (fno) attempts to take the elevator to floor number fno.
The value of fno must be legal; if at attempt is made to go above the maximum floor
number, print the console message:
"Trying to go past top floor"
Similarly, if an attempt is made to go below the minimum floor number, print:
"Trying to go below bottom floor"
In both of the above cases, do not move the elevator.
No message is needed for a legal elevator move.
The methods GoDownOneFloor, and GoUpOneFloor have obvious meaning.
Again, you must guard against illegal floors. In particular, If GoDownOneFloor tries to
go below the minimum floor number, print the console message:
"Trying to go below bottom floor"
If the method GoUpOneFloor tries to go past the maximum floor number, print:
"Trying to go above top floor"
anElevator.GoToFloor(5)
Console.WriteLine("Time to get to floor 9 is {0:F2} seconds", _
anElevator.TimeToFloor(9))
The method TimeToFloor(fno) returns the number of seconds it will take to go from the
elevator’s current floor to floor fno. Your class should contain an attribute timePerFloor
whose constant value is 2.5 seconds (a double). Use this for your computation.
anElevator.Empty()
Console.WriteLine("It is " _
& anElevator.IsEmpty.ToString.ToLower _
& " that the elevator is empty")
Console.WriteLine("It is " _
& anElevator.IsFull.ToString.ToLower _
& " that the elevator is full")
anElevator.Status()
Console.WriteLine()
The method Empty should have all passengers leave the elevator.
Similarly a method Full should result in the elevator having its maximum number of
passengers.
The property IsEmpty should return True or False, a Boolean, depending on the
occupancy of the elevator. Similarly, the property IsFull should return True or False, a
Boolean, also depending on the occupancy of the elevator. These two methods should
only return values.
The remaining code in this module tests that various methods do not behave incorrectly;
no new methods are used.


AnswerRe: An elevator Problem Pin
benjymous5-Mar-07 1:37
benjymous5-Mar-07 1:37 
QuestionEnabling checkbox functioanlity in datagrid Pin
salon4-Mar-07 17:48
salon4-Mar-07 17:48 
QuestionAssigning a TextBox object to another TextBox object Pin
GunaChinna4-Mar-07 17:32
GunaChinna4-Mar-07 17:32 
AnswerRe: Assigning a TextBox object to another TextBox object Pin
S. Senthil Kumar4-Mar-07 18:46
S. Senthil Kumar4-Mar-07 18:46 
GeneralRe: Assigning a TextBox object to another TextBox object Pin
GunaChinna4-Mar-07 19:34
GunaChinna4-Mar-07 19:34 
Questionadding an item to context menu Pin
Muhammad Ashraf Nadeem4-Mar-07 17:06
Muhammad Ashraf Nadeem4-Mar-07 17:06 
AnswerRe: adding an item to context menu Pin
Luc Pattyn4-Mar-07 18:41
sitebuilderLuc Pattyn4-Mar-07 18:41 
QuestionRe: adding an item to context menu Pin
Muhammad Ashraf Nadeem4-Mar-07 19:53
Muhammad Ashraf Nadeem4-Mar-07 19:53 
AnswerRe: adding an item to context menu Pin
jjansen5-Mar-07 0:46
jjansen5-Mar-07 0:46 
AnswerRe: adding an item to context menu Pin
Luc Pattyn5-Mar-07 12:30
sitebuilderLuc Pattyn5-Mar-07 12:30 
Questionrun through every possiblity [modified] Pin
crash8934-Mar-07 16:48
crash8934-Mar-07 16:48 
AnswerRe: run through every possiblity Pin
DavidNohejl5-Mar-07 0:31
DavidNohejl5-Mar-07 0:31 
GeneralRe: run through every possiblity Pin
crash8935-Mar-07 12:34
crash8935-Mar-07 12:34 
QuestionCustom Control and Passing Events Pin
Expert Coming4-Mar-07 16:09
Expert Coming4-Mar-07 16:09 
AnswerRe: Custom Control and Passing Events Pin
pbraun5-Mar-07 8:21
pbraun5-Mar-07 8:21 
Questionrandom number problem Pin
xp20064-Mar-07 15:34
xp20064-Mar-07 15:34 
AnswerRe: random number problem Pin
Sylvester george4-Mar-07 20:12
Sylvester george4-Mar-07 20:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.