|
-
Mar 13th, 2004, 04:59 AM
#1
Thread Starter
Fanatic Member
inherited class-check were ive gone wrong
can someone check where i am going wrong?
I have a form with a map on it. There are several doors. A person has to nevigate through the map. A person cannot be at location 1(represented by ID1 etc) and access door 6. They have to go through the certain doors. So basically they cannot just transport from one place to another.
Attached is a picture of the map.
I have two, classes, a door class and a location class.
I have a feeling ive gone wrong some where but i dont know where. can some one help? Any help will be extremly appreciated.
Public Class location
Private id As Integer
Private securityclearence As Integer
Sub New()
id = 1
securityclearence = 1
End Sub
Sub New(ByVal ids1 As Integer, ByVal isecurityclearence As Integer)
id = 1
securityclearence = 0
End Sub
Public ReadOnly Property ids() As Integer
Get
Return id
End Get
End Property
Public ReadOnly Property sc() As Integer
Get
Return securityclearence
End Get
End Property
Public Function access() As Boolean
If id = 1 Then
securityclearence = 5 Or securityclearence = 4 Or securityclearence = 3 Or securityclearence = 2 Or securityclearence = 1
ElseIf id = 2 Then
securityclearence = 5 Or securityclearence = 4 Or securityclearence = 3 Or securityclearence = 2 Or securityclearence = 1
ElseIf id = 3 Then
securityclearence = 5 Or securityclearence = 4 Or securityclearence = 3 Or securityclearence = 2 Or securityclearence = 1
ElseIf id = 4 Then
securityclearence = 5 Or securityclearence = 4 Or securityclearence = 3 Or securityclearence = 2 Or securityclearence = 1
ElseIf id = 5 Then
securityclearence = 4 Or securityclearence = 3 Or securityclearence = 2 Or securityclearence = 1
ElseIf id = 6 Then
securityclearence = 5 Or securityclearence = 4 Or securityclearence = 3 Or securityclearence = 2 Or securityclearence = 1
ElseIf id = 7 Then
securityclearence = 4 Or securityclearence = 3 Or securityclearence = 2 Or securityclearence = 1
ElseIf id = 8 Then
securityclearence = 4 Or securityclearence = 3 Or securityclearence = 2 Or securityclearence = 1
ElseIf id = 9 Then
securityclearence = 2 Or securityclearence = 1
ElseIf id = 10 Then
securityclearence = 2 Or securityclearence = 1
End If
End Function
End Class
Public Class Door
Inherits location
Protected ID1 As Integer
Protected ID2 As Integer
Private door As String
Sub New()
ID1 = 0
ID2 = 1
Door = "doora"
End Sub
Sub New(ByVal IDs1 As Integer, ByVal IDs2 As Integer, ByVal idoor As String)
ID1 = IDs1
ID2 = IDs2
Door = idoor
End Sub
Public Property ids1() As Integer
Get
Return ID1
End Get
Set(ByVal Value As Integer)
End Set
End Property
Public Property ids2() As Integer
Get
Return ID2
End Get
Set(ByVal Value As Integer)
End Set
End Property
Public Property idoor() As String
Get
Return door
End Get
Set(ByVal Value As String)
End Set
End Property
Public Function doorlocation() As Boolean
If door = "DoorA" Then
ID1 = 0
ID2 = 1
ElseIf door = "Door1" Then
ID1 = 1
ID2 = 2
ElseIf door = "Door2" Then
ID1 = 2
ID2 = 3
ElseIf door = "Door3" Then
ID1 = 2
ID2 = 4
ElseIf door = "Door4" Then
ID1 = 2
ID2 = 5
ElseIf door = "Door5" Then
ID1 = 2
ID2 = 6
ElseIf door = "DoorC" Then
ID1 = 2
ID2 = 7
ElseIf door = "Door6" Then
ID1 = 8
ID2 = 7
ElseIf door = "Door7" Then
ID1 = 9
ID2 = 7
ElseIf door = "Door8" Then
ID1 = 10
ID2 = 7
ElseIf door = "DoorB" Then
ID1 = 0
ID2 = 7
ElseIf door = "DoorD" Then
ID1 = 7
ID2 = 0
End If
End Function
End Class
this is the where the classes are called.
Private Sub Label5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label5.Click
Dim s1 As Door
If s1.idoor <> "Door1" Then
MsgBox("You cannot access this room. You are not in the correct region", MsgBoxStyle.Critical, "Door A")
Else
s1.ids1 = 2
s1.ids2 = 1
End If
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|