Exercise
Class ScreenText
Objetive
Create a class ScreenText, to display a certain text in specified screen coordinates. It must have a constructor which will receive X, Y and the string to write. It must also have 3 setters and a "Display" method.
Create a class CenteredText, based on ScreenText, to display text centered (horizontally) in a certain row of the screen. Its constructor will receive only Y and the text. SetX should not change the horizontal position.
Create a class FramedText, to display text centered and inside a rectangle. It will receive the starting row and the text.
Finally, create a test program for all of them, which will create an object of each type and display them.
Code
Imports System
Namespace TextScreen
Class CenteredText
Inherits ScreenText
End Class
End Namespace
Namespace TextScreen
Class Program
Private Shared Sub Main(ByVal args As String())
End Sub
End Class
End Namespace
Namespace TextScreen
Class ScreenText
Protected x, y As Integer
Protected text As String
Public Sub New(ByVal x As Integer, ByVal y As Integer, ByVal text As String)
Me.x = x
Me.y = y
Me.text = text
End Sub
Public Sub SetX(ByVal x As Integer)
Me.x = x
End Sub
Public Sub SetY(ByVal y As Integer)
Me.y = y
End Sub
Public Sub SetText(ByVal text As String)
Me.text = text
End Sub
Public Sub Display()
Console.SetCursorPosition(x, y)
Console.Write(text)
End Sub
End Class
End Namespace