Program for elevator application, Visual Basic Programming

Assignment Help:

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()

'Set time between floors

CElevator.TimePerFloor = 2.5

Dim anElevatorAs 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

The elevator initially should have no passengers and be at the lowest level.

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 GoToTopFloor() and GoToBottomFloor( ) have the meaning you would expect.

The methods GoDownOneFloor, and GoUpOneFloor also have obvious meaning, but 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 a class variable dTimePerFloorwhose value is 2.5 seconds (a double) and set in the first line of the client code. Use this for your computation.

The time go between floors is then printed via:

Console.WriteLine("Time to go between floors is {0:F2} seconds", _

CElevator.TimePerFloor)

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.

 


Related Discussions:- Program for elevator application

Displaying the database - data control, Displaying The Database: The T...

Displaying The Database: The Text box, image box, check box, labels, picture box can be bounded to the data control for exhibiting the data base contents. The two properties a

Web Scraping via program, I''m trying to create a program in VB.net that wi...

I''m trying to create a program in VB.net that will basically load the page within itself and allow you to input data via the program rather than going to the actual site using you

Select case - control statement, Select Case: The Select Case is used ...

Select Case: The Select Case is used for handling the multiple paths. The Select Case computes the expression and depending on the value of the equivalent Case statement execu

Sub and function procedures in code, In your code A, Function has to always...

In your code A, Function has to always be used on the right side of a variable assignment or in an expression. For illustration: Temp = Celsius(fDegrees) or Msg Box "The C

Programming, i have connected my visual basic 2010 express in ports and use...

i have connected my visual basic 2010 express in ports and use it to send sms but it failed... now my teacher said that i have to use my LAN not port to send it instead..... please

Student record management system, i need your help in designing and coding ...

i need your help in designing and coding a student record management system

Genetics, GENETICS 1.         The branch genetics started in 1900 after...

GENETICS 1.         The branch genetics started in 1900 after rediscovery of Mendel's work. 2.         Gregor Johann Mendel is called Father of genetics. 3.         The t

John Galt requests a program to double-check his Gas Bill, John''s gas supp...

John''s gas supply is read from a 4-digit meter each month that shows the current total gas used in cubic meters. The amount of gas used that month is determined by subtracting t

Multiple document interface (mdi) windows , MULTIPLE DOCUMENT INTERFACE (MD...

MULTIPLE DOCUMENT INTERFACE (MDI) WINDOWS   The SDI (Single document interface) supports one open window or document at a particular time. Microsoft's notepad and paint are il

Visual processing - visual interface design, Visual Processing: Our mi...

Visual Processing: Our mind groups the things into patterns and this allows us to process the visual information. Understanding and applying how the human mind processes the v

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd