VERSION 1.0 CLASS BEGIN MultiUse = -1 'True Persistable = 0 'NotPersistable DataBindingBehavior = 0 'vbNone DataSourceBehavior = 0 'vbNone MTSTransactionMode = 0 'NotAnMTSObject END Attribute VB_Name = "Aircraft" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = True Attribute VB_PredeclaredId = False Attribute VB_Exposed = False Attribute VB_Description = "A basic aircraft model" Attribute VB_Ext_KEY = "SavedWithClassBuilder6" ,"Yes" Attribute VB_Ext_KEY = "Top_Level" ,"Yes" 'aircraft class 'a simple class file designed to model 'an aircraft in an Air Traffic Control simulation 'Andy Harris, 2/99 'local variable(s) to hold property value(s) Private mvaraltitude As Integer 'local copy Private mvardirection As DirecTypes 'local copy Private mvarx As Integer 'local copy Private mvary As Integer 'local copy Private mvarmoving As Boolean 'local copy Private speedVal As Integer 'how many units to move each time Public Enum DirecTypes NORTHWEST = 0 NORTH = 1 NORTHEAST = 2 EAST = 3 SOUTHEAST = 4 SOUTH = 5 SOUTHWEST = 6 WEST = 7 End Enum Public Sub turnRight() If Me.direction < 7 Then Me.direction = Me.direction + 1 Else Me.direction = 0 End If End Sub Public Sub turnLeft() If Me.direction > 0 Then Me.direction = Me.direction - 1 Else Me.direction = 7 End If End Sub Public Sub land() If Me.altitude > 5 Then MsgBox "you are too high to land" Else Me.moving = False Me.altitude = 0 End If End Sub Public Sub takeOff() Attribute takeOff.VB_Description = "Allow plane to take off" Me.moving = True Me.altitude = 5 End Sub Public Sub move() 'analyzes direction, generates new values for x and y 'expects CARTESIAN coordinates (Y is larger at top of page) If (Me.moving = True) Then Select Case Me.direction Case NORTH Me.x = Me.x + 0 Me.y = Me.y + speedVal Case NORTHEAST Me.x = Me.x + speedVal Me.y = Me.y + speedVal Case EAST Me.x = Me.x + speedVal Me.y = Me.y + 0 Case SOUTHEAST Me.x = Me.x + speedVal Me.y = Me.y - speedVal Case SOUTH Me.x = Me.x + 0 Me.y = Me.y - speedVal Case SOUTHWEST Me.x = Me.x - speedVal Me.y = Me.y - speedVal Case WEST Me.x = Me.x - speedVal Me.y = Me.y + 0 Case NORTHWEST Me.x = Me.x - speedVal Me.y = Me.y + speedVal End Select End If End Sub Public Property Let moving(ByVal vData As Boolean) 'used when assigning a value to the property, on the left side of an assignment. 'Syntax: X.moving = 5 mvarmoving = vData End Property Public Property Get moving() As Boolean 'used when retrieving value of a property, on the right side of an assignment. 'Syntax: Debug.Print X.moving moving = mvarmoving End Property Public Property Let y(ByVal vData As Integer) 'used when assigning a value to the property, on the left side of an assignment. 'Syntax: X.y = 5 mvary = vData End Property Public Property Get y() As Integer 'used when retrieving value of a property, on the right side of an assignment. 'Syntax: Debug.Print X.y y = mvary End Property Public Property Let x(ByVal vData As Integer) 'used when assigning a value to the property, on the left side of an assignment. 'Syntax: X.x = 5 mvarx = vData End Property Public Property Get x() As Integer 'used when retrieving value of a property, on the right side of an assignment. 'Syntax: Debug.Print X.x x = mvarx End Property Public Property Let direction(ByVal vData As DirecTypes) 'used when assigning a value to the property, on the left side of an assignment. 'Syntax: X.direction = 5 If (vData < 0) Or (vData > 7) Then MsgBox "vData is " + Str(vData) MsgBox "Illegal value! Setting direction to NORTH" mvardirection = NORTH Else mvardirection = vData End If End Property Public Property Get direction() As DirecTypes 'used when retrieving value of a property, on the right side of an assignment. 'Syntax: Debug.Print X.direction direction = mvardirection End Property Public Property Let altitude(ByVal vData As Integer) Attribute altitude.VB_Description = "Tells how high the plane is (in 100 ft increments)" 'used when assigning a value to the property, on the left side of an assignment. 'Syntax: X.altitude = 5 mvaraltitude = vData End Property Public Property Get altitude() As Integer 'used when retrieving value of a property, on the right side of an assignment. 'Syntax: Debug.Print X.altitude altitude = mvaraltitude End Property Private Sub Class_Initialize() speedVal = 5 Me.direction = NORTH End Sub