Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Here\'s my code: Public Class Product Public Property Name() As String Public Ev

ID: 3530343 • Letter: H

Question

Here's my code:


Public Class Product

Public Property Name() As String

Public Event PriceChanged()

Private _price As Decimal
Public Property Price() As Decimal
Get
Return _price
End Get
Set(ByVal value As Decimal)
_price = value

' Fire the event to all listeners.
RaiseEvent PriceChanged()
End Set
End Property

Public Property ImageUrl() As String

Public Function GetHtml() As String
Dim htmlString As String
htmlString = "<h1>" & Name & "</h1><br />"
htmlString &= "<h3>Costs: " & Price.ToString() & "</h3><br />"
htmlString &= "<img src="" &amp; ImageUrl &amp; "" />"
Return htmlString
End Function

Public Sub New(ByVal name As String, ByVal price As Decimal)
Me.Name = name
Me.Price = price
End Sub
Public Sub New(ByVal name As String, ByVal price As Decimal, _
ByVal imageUrl As String)
Me.Name = name
Me.Price = price
Me.ImageUrl = imageUrl
End Sub

End Class




This is what needs to be done(could you please leave comments as well in front of codes such as //class Myclass and such. thanks):

Create a class called MyClass. Add a property called name.


Add a constructor to the class that sets the value of name to the name that is passed into the constructor.


Add a method called "AddNumbers" that accepts 2 numbers as parameters, adds them and returns the result.


Add a method called "FindTrianglarNumber" that accepts an integer and that will add all numbers between 1 and that number and returns the result using a for loop.


On the default.aspx page under the page load method, create a new instance of MyClass and do a response.write in order to display the results to the screen


Explanation / Answer

Public Class MyClass Private name As String // property // below is constructor Property MyClass() As String Get Return name End Get Set(ByVal Value As String) name= Value End Set End Property Public Function AddNumbers(ByVal num1 As String,ByVal num2 As String) As String int sum sum=Convert.ToInt32(num1)+Convert.ToInt(num2) Return sum End Function End Class