Shape Hierarchy

Terabojin

Active member
Joined
Mar 4, 2012
Messages
33
Programming Experience
Beginner
Hello,

I am having some trouble with this code. I know that I am supposed to use an array, however I cannot figure out how to do so. This code is not giving me any output, its not taking any input, and its throwing me tons of errors I cant figure out how to get rid of. Here is the code that I presently have with the problem stated before the code in comments:
Module ShapeHierarchy
    'Implement a portion of the shape hierarchy shown in Fig. 10.3.  
    'You should implement the two-dimensional shapes Circle and Square and the three-dimensional 
    'shapes sphere and Cube.  Each two dimensional Shape should contain method GetArea to
    'calculate the area of the two-dimensional shape.  Each three-dimensional shape should have methods 
    'GetArea and GetVolume to calculate the surface area and volume, respectively,
    'of the three-dimensional shape.  Use the following formulas for the area and volume of the various shapes:
    'a) area of a square : side * side
    'b) area of a circle: Math.PI * Radius, where radius is the radius of a circle
    'c) area of a sphere: 4 * Math.PIb* Radius * Radius, where radius is the radius of a sphere
    'd) volume of a sphere: (4/3) * Math.PI *Radius * Radius * Radius
    'e) area of a cube: 6 * side * side
    'f) voolume of a cube: side * side * side
    'Create a program that uses an array of shape references to objects of each concrete class in the hierarchy. 
    'The program should display a string of each object.  Each object's ToString method should display all of that object's data, its area and, for 
    'three-dimensional shapes, its volume.
    'Create a console application. Prompt the user for a shape (provide a list of the shapes available) and the appropriate data needed to compute the area and/or volume. 
    Sub Main()
        'creates the screen that allows the user to select which shape they want
        Dim KeyPressed As ConsoleKeyInfo
        Console.WriteLine("Enter the Number of the Shape to be Computed")
        Console.WriteLine()
        Console.WriteLine("1) Compute the Area of a Square")
        Console.WriteLine("2) Compute the Area of a a Circle")
        Console.WriteLine("3) Compute the Area of a a Cube")
        Console.WriteLine("4) Compute the Area of a Sphere")
        Console.WriteLine("5) Compute the Voume of a Cube")
        Console.WriteLine("6) Compute the Volume of a Sphere")
        Console.WriteLine()
        Console.WriteLine("Press <ESC> to Quit!")
        Do
            KeyPressed = Console.ReadKey(True)
            Select Case KeyPressed.Key
                'square area code
                Case ConsoleKey.D1
                    Dim mySquare As Square
                    mySquare = GetSquareDetails()
                    Console.WriteLine(mySquare.ToString)
                    'circle area code
                Case ConsoleKey.D2
                    Dim myCircle As Circle
                    myCircle = GetCircleDetails()
                    Console.WriteLine(myCircle.ToString)
                    'cube area code
                Case ConsoleKey.D3
                    Dim myCube As Cube
                    myCube = GetCubeDetails()
                    Console.WriteLine(myCube.ToString)
                    'sphere area code
                Case ConsoleKey.D4
                    Dim mySphere As Sphere
                    mySphere = GetSphereDetails()
                    Console.WriteLine(mySphere.ToString)
            End Select
        Loop While Not KeyPressed.Key = ConsoleKey.Escape
    End Sub
    'function that gets square details
    Private Function GetSquareDetails() As Square
        'define a new square, a string variable to get info from user, and boolean variable to check continuation
        Dim GetSquare As New Square
        Dim GetValue As String
        Dim ValueIsValidated As Boolean
        Console.WriteLine()
        Console.WriteLine("Enter then Size of the Sides of the Square:-")
        Do
            GetValue = Console.ReadLine()
            'get input from user
            If Single.TryParse(GetValue, GetSquare, SizeofSide) Then
                ValueIsValidated = True
            Else
                'if input is invalid tells user to enter a valid value
                Console.WriteLine("Please Enter a Valid Number for the Size of a Square!")
            End If
        Loop Until ValueIsValidated
        Return GetSquare
    End Function
End Module
'class that defines a square
Public Class Square
    Public Property SizeofSide As Single
    'function that calculates area of square
    Public Function GetArea() As Single
        Return SizeofSide * SizeofSide
    End Function
    'overrides the default class ToString function and creates own
    Public Overrides Funtion ToString() As String
        Return "The sides of the sides are " & SizeofSide & " and the Area of the square is " & FormatNumber(GetArea(), 4)
    End Function
End Class
'function that gets circle details
Private Function GetCircleDetails() As Circle
    'define a new circle, a string variable to get info from user, and boolean variable to check continuation
    Dim GetCircle As New C‏ircle
    Dim GetValue As String
    Dim ValueIsValidated As Boolean
    Console.WriteLine()
    Console.WriteLine("Enter then radius of the circle:-")
    Do
        GetValue = Console.ReadLine()
        'get input from user
        If Single.TryParse(GetValue, GetCircle, Radius) Then
            ValueIsValidated = True
        Else
            'if input is invalid tells user to enter a valid value
            Console.WriteLine("Please Enter a Valid Number for the Radius of a Circle!")
        End If
    Loop Until ValueIsValidated
    Return GetCircle
End Function
End Module
'class that defines a Circle
Public Class Circle
    Public Property Radius As Single
    'function that calculates area of circle
    Public Function GetArea() As Single
        Return Math.PI * Radius * Radius
    End Function
    'overrides the default class ToString function and creates own
    Public Overrides Funtion ToString() As String
        Return "The Radius of a circle " & Radius & " and the Area of the Circle is " & FormatNumber(GetArea(), 4)
    End Function
End Class
'function that gets cube details
Private Function GetCubedetails() As Cube
    'define a new cube, a string variable to get info from user, and boolean variable to check continuation
    Dim GetCube As New Cube
    Dim GetValue As String
    Dim ValueIsValidated As Boolean
    Console.WriteLine()
    Console.WriteLine("Enter the Side of the Cube:-")
    Do
        GetValue = Console.ReadLine()
        'get input from user
        If Single.TryParse(GetValue, GetCube, Side) Then
            ValueIsValidated = True
        Else
            'if input is invalid tells user to enter a valid value
            Console.WriteLine("Please Enter a Valid Number for the side of the Cube!")
        End If
    Loop Until ValueIsValidated
    Return GetCube
End Function
End Module
'class that defines a Cube
Public Class Cube
    Public Property Side As Single
    'function that calculates area of Cube
    Public Function GetArea() As Single
        Return 6 * Side * Side
    End Function
    'overrides the default class ToString function and creates own
    Public Overrides Funtion ToString() As String
        Return "The Side of a Cube " & Side & " and the Area of the Cube is " & FormatNumber(GetArea(), 4)
    End Function
End Class

'function that gets sphere's area details
Private Function GetShperedetails() As Sphere
    'define a new , a string variable to get info from user, and boolean variable to check continuation
    Dim GetShere As New Sphere
    Dim GetValue As String
    Dim ValueIsValidated As Boolean
    Console.WriteLine()
    Console.WriteLine("Enter the Radus of the Sphere:-")
    Do
        GetValue = Console.ReadLine()
        'get input from user
        If Single.TryParse(GetValue, GetSphere, Radius) Then
            ValueIsValidated = True
        Else
            'if input is invalid tells user to enter a valid value
            Console.WriteLine("Please Enter a Valid Number for the radius of the Sphere!")
        End If
    Loop Until ValueIsValidated
    Return GetSphere
End Function
End Module
'class that defines a Sphere
Public Class Sphere
    Public Property Radius As Single
    'function that calculates area of Sphere
    Public Function GetArea() As Single
        Return 4 * Math.PI * Radius
    End Function
    'overrides the default class ToString function and creates own
    Public Overrides Funtion ToString() As String
        Return "The radius of a sphere " & Radius & " and the area of the Sphere is " & FormatNumber(GetArea(), 4)
    End Function
End Class

'function that gets cube's volume details
Private Function GetCubeVoldetails() As CubeVol
    'define a new cube, a string variable to get info from user, and boolean variable to check continuation
    Dim GetCubeVol As New CubeVol
    Dim GetValue As String
    Dim ValueIsValidated As Boolean
    Console.WriteLine()
    Console.WriteLine("Enter the Side of the Cube:-")
    Do
        GetValue = Console.ReadLine()
        'get input from user
        If Single.TryParse(GetValue, GetCube, Side) Then
            ValueIsValidated = True
        Else
            'if input is invalid tells user to enter a valid value
            Console.WriteLine("Please Enter a Valid Number for the side of the Cube!")
        End If
    Loop Until ValueIsValidated
    Return GetCubeVol
End Function
End Module
'class that defines a CubeVolume
Public Class CubeVol
    Public Property Side As Single
    'function that calculates volume of Cube
    Public Function GetVolume() As Single
        Return Side * Side * Side
    End Function
    'overrides the default class ToString function and creates own
    Public Overrides Funtion ToString() As String
        Return "The Side of a Cube " & Side & " and the Volume of the Cube is " & FormatNumber(GetArea(), 4)
    End Function
End Class

'function that gets Sphere's volume details
Private Function GetSphereVoldetails() As SphereVol
    'define a new spherevol, a string variable to get info from user, and boolean variable to check continuation
    Dim GetSphereVol As New SphereVol
    Dim GetValue As String
    Dim ValueIsValidated As Boolean
    Console.WriteLine()
    Console.WriteLine("Enter the Radius of the Sphere:-")
    Do
        GetValue = Console.ReadLine()
        'get input from user
        If Single.TryParse(GetValue, GetSphereVol, Radius) Then
            ValueIsValidated = True
        Else
            'if input is invalid tells user to enter a valid value
            Console.WriteLine("Please Enter a Valid Number for the radius of the Sphere!")
        End If
    Loop Until ValueIsValidated
    Return GetSphereVol
End Function
End Module
'class that defines a Sphere's Volume
Public Class SphereVol
    Public Property Radius As Single
    'function that calculates volume of Sphere
    Public Function GetVolume() As Single
        Return (4 / 3) * Math.PI * Radius * Radius * Radius
    End Function
    'overrides the default class ToString function and creates own
    Public Overrides Funtion ToString() As String
        Return "The Radius of a Sphere " & Sphere & " and the Volume of the Sphere is " & FormatNumber(GetArea(), 4)
    End Function
End Class



please help me?
 
Last edited:
I can't speak for everybody but there's no way that I will be reading all that code and hoping to find one of these numerous issues that you mention occur but give no details about. How about you start with one specific issue? Tell us exactly what the error message is, where it occurs and under what circumstances. We can then address that specifically and then move onto the next.
 
this is the list of errors that i am getting from my code
line 95 column : end function must be preceded by a mating function'
line 135 column 5 : ""
line 169 colimn 5: ""
line 283 column 5: ""
line 119 column 1: end module must be preceded by a matching module
line 156 column 1: ""
line 232 colmn 1: ""
line 45 column 32: GetCircleDetails is not declared. it may be inaccessible due to its protection lvl
line 50 column 30: GetCubeDetails is not declared. it may be inaccessible due to its protection lvl
line 55 column 32: GetSphereDetails is not declared. it may be inaccessible due to its protection lvl
line 93 column 12: Overrides is not valid on a member variable declaration
line 130 column 12: ""
line 167 column 12: ""
line 205 column 12: ""
line 243 column 12: ""
line 281 column 12: ""
line 73 column 53: SizeofSide is not declares. may be inaccessible due to its protection lvl
line 93 column 30: end of statement expected
line 130 column 30: ""
line 167 column 30: ""
line 205 column 30: ""
line 243 column 30: ""
line 94 colimn 9: statement cannot appear outide of a method body/multiline lambda
line 131 column 9: ""
line 168 column 9: ""
line 206 column 9: ""
line 244 column 9: ""
line 282 column 9: ""
line 99 column 1: statement is not a valid namespace
line 136 column 1: ""
line 74 column 1: ""
line 212 column 1: ""
line 25 column 1: ""
 
I don't think that the line numbers that you've posted match up to the line numbers in your code snippet but those error messages have at least given an indication of what to look for. In the code snippet you have posted, line 1 starts a module and that module ends on line 77. That's followed by a class that starts on line 79 and ends on line 89. All's well so far. You then have a function that starts on line 91 and ends on line 109. That's the first issue. Functions cannot exist just on their own. They have to be declared inside a type, i.e. a module, class or structure. That's followed by an End Module on line 110 but there's no corresponding Module declaration. That's theme is repeated several times through the code. It looks like those naked methods are supposed to be inside a module.
 
Ok now I am down to errors and here is the code I am currently working with:

Module ShapeHierarchy
    'Implement a portion of the shape hierarchy shown in Fig. 10.3.  
    'You should implement the two-dimensional shapes Circle and Square and the three-dimensional 
    'shapes sphere and Cube.  Each two dimensional Shape should contain method GetArea to
    'calculate the area of the two-dimensional shape.  Each three-dimensional shape should have methods 
    'GetArea and GetVolume to calculate the surface area and volume, respectively,
    'of the three-dimensional shape.  Use the following formulas for the area and volume of the various shapes:
    'a) area of a square : side * side
    'b) area of a circle: Math.PI * Radius, where radius is the radius of a circle
    'c) area of a sphere: 4 * Math.PIb* Radius * Radius, where radius is the radius of a sphere
    'd) volume of a sphere: (4/3) * Math.PI *Radius * Radius * Radius
    'e) area of a cube: 6 * side * side
    'f) voolume of a cube: side * side * side
    'Create a program that uses an array of shape references to objects of each concrete class in the hierarchy. 
    'The program should display a string of each object.  Each object's ToString method should display all of that object's data, its area and, for 
    'three-dimensional shapes, its volume.
    'Create a console application. Prompt the user for a shape (provide a list of the shapes available) and the appropriate data needed to compute the area and/or volume. 

    Sub Main()
        'creates the screen that allows the user to select which shape they want        
        Dim KeyPressed As ConsoleKeyInfo
        
        Dim myShapes(0) As Shape
        Console.WriteLine("Enter the Number of the Shape to be Computed")
        Console.WriteLine()
        Console.WriteLine("1) Compute the Area of a Square")
        Console.WriteLine("2) Compute the Area of a a Circle")
        Console.WriteLine("3) Compute the Area of a a Cube")
        Console.WriteLine("4) Compute the Area of a Sphere")
        Console.WriteLine("5) Compute the Voume of a Cube")
        Console.WriteLine("6) Compute the Volume of a Sphere")
        'I have added this option 7 now to display the contents of the array 
        Console.WriteLine("7) Display All Shapes Entered So Far")
        Console.WriteLine()
        Console.WriteLine("Press <ESC> to Quit!")
        Do
            'here I have used Console.ReadKey(True) to get the keystrokes on the screen - the True parameter means
            'do not display typed charaters to the screen since you are only interested in specific charaters
            'if you want to see everything you type then just remnove the true value
            KeyPressed = Console.ReadKey(True)
            Select Case KeyPressed.Key
                Case ConsoleKey.D1
                    'square area code                
                    Dim mySquare As Square
                    mySquare = GetSquareDetails()
                    Console.WriteLine(mySquare.ToString)
                    'here is where I save the shape after it has been entered 
                    SaveShape(myShapes, mySquare)
                Case ConsoleKey.D2
                    'circle area code                
                    Dim myCircle As Circle
                    myCircle = GetCircleDetails()
                    Console.WriteLine(myCircle.ToString)
                    SaveShape(myShapes, myCircle)
                Case ConsoleKey.D3
                    'cube area code                
                    Dim myCube As Cube
                    myCube = GetCubeDetails()
                    Console.WriteLine(myCube.ToString)
                    SaveShape(myShapes, myCube)
                Case ConsoleKey.D4
                    'sphere area code                
                    Dim mySphere As Sphere
                    mySphere = GetSphereDetails()
                    Console.WriteLine(mySphere.ToString)
                    SaveShape(myShapes, mySphere)
                Case ConsoleKey.D5
                    'cube volume code
                    Dim myCubeVol As Cube
                    myCubeVol = GetCubeVolDetails()
                    Console.WriteLine(myShapes, myCubeVol)
                    SaveShapes(myShapes, myCubeVol)

                Case ConsoleKey.D6
                    'sphere volume code
                    Dim mySphereVol As Sphere
                    mySphereVol = GetSphereVolDetails()
                    SaveShapes(myShapes, mySphereVol)

                Case ConsoleKey.D7
                    'this is where I loop through the shapes array and display all the shape results when the
                    'number 7 button is pressed on the keyboard
                    For Each EnteredShape As Shape In myShapes
                        Console.WriteLine(EnteredShape.ToString)
                    Next
            End Select
        Loop While Not KeyPressed.Key = ConsoleKey.Escape
    End Sub
    'this is the save shape routine. It uses a static variable to kkeep track of the
    'number of shapes that have been entered. It then uses this variable to
    're-dimention the array the the correct size so that the new shape can be saved
    'without destroying the shapes that have been previously entered
    Private Sub SaveShape(ByRef myShapes() As Shape, ByVal enteredShape As Shape)
        Static CountShapesEntered As Integer
        ReDim Preserve myShapes(CountShapesEntered)
        myShapes(CountShapesEntered) = enteredShape
        CountShapesEntered += 1
    End Sub
    'function that gets square details    
    Private Function GetSquareDetails() As Square
        'define a new square, a string variable to get info from user, and boolean variable to check continuation        
        Dim GetSquare As New Square
        Dim GetValue As String
        Dim ValueIsValidated As Boolean
        Console.WriteLine()
        Console.WriteLine("Enter then Size of the Sides of the Square:-")
        Do
            GetValue = Console.ReadLine()
            'get input from user            
            If Single.TryParse(GetValue, GetSquare.SizeofSide) Then
                ValueIsValidated = True
            Else
                'if input is invalid tells user to enter a valid value                
                Console.WriteLine("Please Enter a Valid Number for the Size of a Square!")
            End If
        Loop Until ValueIsValidated
        Return GetSquare
    End Function
    'function that gets circle details
    Private Function GetCircleDetails() As Circle
        'define a new circle, a string variable to get info from user, and boolean variable to check continuation    
        Dim GetCircle As New Circle
        Dim GetValue As String
        Dim ValueIsValidated As Boolean
        Console.WriteLine()
        Console.WriteLine("Enter then radius of the circle:-")
        Do
            GetValue = Console.ReadLine()
            'get input from user        
            If Single.TryParse(GetValue, GetCircle.Radius) Then
                ValueIsValidated = True
            Else
                'if input is invalid tells user to enter a valid value            
                Console.WriteLine("Please Enter a Valid Number for the Radius of a Circle!")
            End If
        Loop Until ValueIsValidated
        Return GetCircle
    End Function
    'function that gets square details    
    Private Function GetCubeDetails() As Cube
        'define a new cubr, a string variable to get info from user, and boolean variable to check continuation        
        Dim GetCube As New Cube
        Dim GetValue As String
        Dim ValueIsValidated As Boolean
        Console.WriteLine()
        Console.WriteLine("Enter then Size of the Sides of the Cube:-")
        Do
            GetValue = Console.ReadLine()
            'get input from user            
            If Single.TryParse(GetValue, GetCube.SizeofSide) Then
                ValueIsValidated = True
            Else
                'if input is invalid tells user to enter a valid value                
                Console.WriteLine("Please Enter a Valid Number for the Size of a Cube!")
            End If
        Loop Until ValueIsValidated
        Return GetCube
    End Function
    'function that gets sphere details    
    Private Function GetSphereDetails() As Sphere
        'define a new sphere, a string variable to get info from user, and boolean variable to check continuation        
        Dim GetSphere As New Sphere
        Dim GetValue As String
        Dim ValueIsValidated As Boolean
        Console.WriteLine()
        Console.WriteLine("Enter then Size of the Radius of the Sphere:-")
        Do
            GetValue = Console.ReadLine()
            'get input from user            
            If Single.TryParse(GetValue, GetSphere.Radius) Then
                ValueIsValidated = True
            Else
                'if input is invalid tells user to enter a valid value                
                Console.WriteLine("Please Enter a Valid Number for the Size of the Radius!")
            End If
        Loop Until ValueIsValidated
        Return GetSphere
        'function that gets cube volume details    
    Private Function GetCubeVolDetails() As CubeVol
        'define a new cube, a string variable to get info from user, and boolean variable to check continuation        
        Dim GetCubeVol As New CubeVol
        Dim GetValue As String
        Dim ValueIsValidated As Boolean
        Console.WriteLine()
        Console.WriteLine("Enter then Size of the Sides of the Cube:-")
        Do
            GetValue = Console.ReadLine()
            'get input from user            
            If Single.TryParse(GetValue, GetCubeVol.SizeofSide) Then
                ValueIsValidated = True
            Else
                'if input is invalid tells user to enter a valid value                
                Console.WriteLine("Please Enter a Valid Number for the Size of a Cube!")
            End If
        Loop Until ValueIsValidated
        Return GetCubeVol
    End Function
    'function that gets sphereVolDetails() As SphereVol
    Private Function GetSphereVolDetails() As SphereVol
        'define a new sphere, a string variable to get info from user, and boolean variable to check continuation        
        Dim GetSphereVol As New Sphere
        Dim GetValue As String
        Dim ValueIsValidated As Boolean
        Console.WriteLine()
        Console.WriteLine("Enter then Size of the Radius of the Sphere:-")
        Do
            GetValue = Console.ReadLine()
            'get input from user            
            If Single.TryParse(GetValue, GetSphereVol.Radius) Then
                ValueIsValidated = True
            Else
                'if input is invalid tells user to enter a valid value                
                Console.WriteLine("Please Enter a Valid Number for the Size of the Radius!")
            End If
        Loop Until ValueIsValidated
        Return GetSphereVol
    End Function
End Module
' declared the BASE class shape which can then be used to hold
'all the different shapes in the array defined above by the use of inheritance
Public MustInherit Class Shape
End Class
'class that defines a square
Public Class Square
    'notice inheritance here
    Inherits Shape
    Public Property SizeofSide As Single
    'function that calculates area of square    
    Public Function GetArea() As Single
        Return SizeofSide * SizeofSide
    End Function
    'overrides the default class ToString function and creates own
    Public Overrides Function ToString() As String
        Return "The sides of the sides are " & SizeofSide & " and the Area of the square is " & FormatNumber(GetArea(), 4)
    End Function
End Class
'class that defines a Circle
Public Class Circle
    'notice inheritance here
    Inherits Shape
    Public Property Radius As Single
    'function that calculates area of circle    
    Public Function GetArea() As Single
        Return CSng(Math.PI * Radius * Radius)
    End Function
    'overrides the default class ToString function and creates own    
    Public Overrides Function ToString() As String
        Return "The Radius of a circle " & Radius & " and the Area of the Circle is " & FormatNumber(GetArea(), 4)
    End Function
End Class
'class that defines a Sphere
Public Class Sphere
    'notice inheritance here
    Inherits Shape
    Public Property Radius As Single
    'function that calculates area of Sphere
    Public Function GetArea() As Single
        Return CSng(Math.PI * Radius)
    End Function
    'overrides the default class ToString function and creates own
    Public Overrides Function ToString() As String
        Return "The radius of a sphere " & Radius & " and the area of the Sphere is " & FormatNumber(GetArea(), 4)
    End Function
End Class
'class that defines a cube
Public Class Cube
    'notice Inheritance here
    Inherits Shape
    Public Property SizeofSide As Single
    'function that calculates the area of a cube
    Public Function GetArea() As Single
        Return CSng(6 * SizeofSide * SizeofSide)
    End Function
    'overrides the default class ToString function and creates own
    Public Overrides Function ToString() As String
        Return "The Side of a Cube " & SizeofSide & " and the Area of the Cube is " & FormatNumber(GetArea(), 4)
    End Function
End Class
'class that defines a cubes volume
Public Class CubeVol
    'notice Inheritance here
    Inherits Shape
    Public Property SizeofSide As Single
    'function that calculates the volume of a cube
    Public Function GetVolume() As Single
        Return CSng(SizeofSide * SizeofSide * SizeofSide)
    End Function
    'overrides the default class ToString function and creates own
    Public Overrides Function ToString() As String
        Return "The Side of a Cube " & SizeofSide & " and the Volume of a Cube is " & FormatNumber(GetVolume(), 4)
    End Function
End Class
'class that defines the volume of a sphere
Public Class SphereVol
    'notice Inheritance here
    Inherits Shape
    Public Property Radius As Single

    'function that calculates the volume of a sphere
    Public Function GetVolume() As Single
        Return CSng((4 / 3) * Math.PI * Radius * Radius * Radius)
    End Function
    'overrides the default class ToString function and creates own
    Public Overrides Function ToString() As String
        Return "The Radius of a Sphere " & Radius & " and the Volume of a Spher is " & FormatNumber(GetVolume(), 4)
    End Function
End Class



here are the errors I am recieving:

Error 3 'SaveShapes' is not declared. It may be inaccessible due to its protection level. C:\Users\Tera\Documents\Visual Studio 2010\Projects\cisp370Asgn10-w1391778\cisp370Asgn10-w1391778\ShapeHierarchy.vb 78 21 cisp370Asgn10-w1391778
Error 5 'SaveShapes' is not declared. It may be inaccessible due to its protection level. C:\Users\Tera\Documents\Visual Studio 2010\Projects\cisp370Asgn10-w1391778\cisp370Asgn10-w1391778\ShapeHierarchy.vb 85 21 cisp370Asgn10-w1391778
Error 6 Statement cannot appear within a method body. End of method assumed. C:\Users\Tera\Documents\Visual Studio 2010\Projects\cisp370Asgn10-w1391778\cisp370Asgn10-w1391778\ShapeHierarchy.vb 193 5 cisp370Asgn10-w1391778
Error 2 Value of type '1-dimensional array of cisp370Asgn10_w1391778.Shape' cannot be converted to 'String'. C:\Users\Tera\Documents\Visual Studio 2010\Projects\cisp370Asgn10-w1391778\cisp370Asgn10-w1391778\ShapeHierarchy.vb 77 39 cisp370Asgn10-w1391778
Error 1 Value of type 'cisp370Asgn10_w1391778.CubeVol' cannot be converted to 'cisp370Asgn10_w1391778.Cube'. C:\Users\Tera\Documents\Visual Studio 2010\Projects\cisp370Asgn10-w1391778\cisp370Asgn10-w1391778\ShapeHierarchy.vb 76 33 cisp370Asgn10-w1391778
Error 7 Value of type 'cisp370Asgn10_w1391778.Sphere' cannot be converted to 'cisp370Asgn10_w1391778.SphereVol'. C:\Users\Tera\Documents\Visual Studio 2010\Projects\cisp370Asgn10-w1391778\cisp370Asgn10-w1391778\ShapeHierarchy.vb 231 16 cisp370Asgn10-w1391778
Error 4 Value of type 'cisp370Asgn10_w1391778.SphereVol' cannot be converted to 'cisp370Asgn10_w1391778.Sphere'. C:\Users\Tera\Documents\Visual Studio 2010\Projects\cisp370Asgn10-w1391778\cisp370Asgn10-w1391778\ShapeHierarchy.vb 84 35 cisp370Asgn10-w1391778


I'm not aure what I'm doing wrong, any ideas?
 
correction, i only have 4 errors now that read:

Error 2 'SaveShapes' is not declared. It may be inaccessible due to its protection level. C:\Users\Tera\Documents\Visual Studio 2010\Projects\cisp370Asgn10-w1391778\cisp370Asgn10-w1391778\ShapeHierarchy.vb 78 21 cisp370Asgn10-w1391778
Error 3 'SaveShapes' is not declared. It may be inaccessible due to its protection level. C:\Users\Tera\Documents\Visual Studio 2010\Projects\cisp370Asgn10-w1391778\cisp370Asgn10-w1391778\ShapeHierarchy.vb 85 21 cisp370Asgn10-w1391778
Error 1 Value of type '1-dimensional array of cisp370Asgn10_w1391778.Shape' cannot be converted to 'String'. C:\Users\Tera\Documents\Visual Studio 2010\Projects\cisp370Asgn10-w1391778\cisp370Asgn10-w1391778\ShapeHierarchy.vb 77 39 cisp370Asgn10-w1391778
Error 4 Value of type 'cisp370Asgn10_w1391778.Sphere' cannot be converted to 'cisp370Asgn10_w1391778.SphereVol'. C:\Users\Tera\Documents\Visual Studio 2010\Projects\cisp370Asgn10-w1391778\cisp370Asgn10-w1391778\ShapeHierarchy.vb 232 16 cisp370Asgn10-w1391778


any ideas?
 
Hi,

Firstly SaveShapes shoud be SaveShape. As for the second two you are going to have to pin-point where you are getting these in your code since it is difficult to tell at the moment.

Cheers,

Ian
 
Hi,

Found another one. In your Case ConsoleKey.D6 you declare Dim mySphereVol As Sphere it should be Dim mySphereVol As SphereVol to conform to the return type of your function.

Cheers,

Ian
 
Hi,

Found the last one. In your Case ConsoleKey.D5 you have Console.WriteLine(myShapes, myCubeVol). To conform to your other shape cases this should be Console.WriteLine(myCubeVol.ToString). It also seems you have missed your WriteLine statement in your ConsoleKey.D6 case.

That should be it now so hope that helps.

Cheers,

Ian
 
Back
Top