fork download
  1. Class Course
  2. Public Sub New(id As String, title As String, creditHours As Integer, description As String, prerequisiteCourse As String)
  3. Me.CourseID = id
  4. Me.CourseTitle = title
  5. Me.CreditHours = creditHours
  6. Me.Description = description
  7. Me.PrerequisiteCourse = prerequisiteCourse
  8. End Sub
  9.  
  10.  
  11. Public CourseID As String
  12. Public CourseTitle As String
  13. Public CreditHours As Integer
  14. Public Description As String
  15. Public PrerequisiteCourse As String
  16. End Class
  17. Class CourseList
  18. Public CourseArray As Course() = {New Course("CIS 400", "OO Analysis & Design", 4, "Important class", "CIS 110"), New Course("CIS 150A", "VB.NET Programming", 4, "Good Introduction to programming", "CIS 100"), New Course("CIS 150B", "C# Programming with labs", 4, "Follow-up to CIS 100", "CIS 100")}
  19.  
  20.  
  21. Public Function GetCourseByCourseID(id As String) As Course
  22. If Not String.IsNullOrEmpty(id) Then
  23. For Each course As var In CourseArray
  24. If course.CourseID = id Then
  25. Return course
  26. End If
  27. Next
  28. End If
  29. Return Nothing
  30. End Function
  31. End Class
  32. Class CourseListTest
  33. Public Shared Sub Main(args As String())
  34. GetCourseByCourseIDTestWhenCourseExists()
  35. GetCourseByCourseIDTestWhenCourseDoesNotExist()
  36. End Sub
  37.  
  38.  
  39. Public Shared Sub GetCourseByCourseIDTestWhenCourseExists()
  40.  
  41. Dim myCourseList As New CourseList()
  42. Dim myCourse As Course = myCourseList.GetCourseByCourseID("CIS 400")
  43. If myCourse.CourseID <> "CIS 400" Then
  44. System.Console.WriteLine("ERROR - GetCourseByCourseIDTestWhenCourseExists(): Returned CourseID Not equal (CIS 400)")
  45. End If
  46. End Sub
  47.  
  48. Public Shared Sub GetCourseByCourseIDTestWhenCourseDoesNotExist()
  49.  
  50. Dim myCourseList As New CourseList()
  51. Dim myCourse As Course = myCourseList.GetCourseByCourseID("CIS 101")
  52. If myCourse IsNot Nothing Then
  53. System.Console.WriteLine("ERROR - GetCourseByCourseIDTestWhenCourseDoesNotExist(): should have returned null")
  54. End If
  55. End Sub
  56. End Class
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Visual Basic.Net Compiler version 0.0.0.5943 (Mono 3.8 - tarball)
Copyright (C) 2004-2010 Rolf Bjarne Kvinge. All rights reserved.

/home/IXQp39/prog.vb (23,26) : error VBNC30451: 'var' is not declared. It may be inaccessible due to its protection level.
There were 1 errors and 0 warnings.
Compilation took 00:00:00.7613620
stdout
Standard output is empty