1 Attachment(s)
questions that I need help answering
Look at the demo 3 solution and answer these questions.
1. Why can't we override the property Name in CCustomer?
2. There is no Property for Address in CCustomer, yet we can code
objCustomer.Address = txtAddress.Text. Explain.
3. If you enter no data, but just press Add, the customer lives in Portland. But there is no reference to Portland in the Customer class.
Explain in light of the fact that constructors are not inherited.
4. SalesYTD is $78,000, but SalesYTD is a ReadOnly Property.
Where does it obtain its value?
What value(s) should we enter to verify that we never sell to minors (people under 18)? Does our logic work? Why or why not?
Re: questions that I need help answering
Quote:
Originally posted by nicky.1
Look at the demo 3 solution and answer these questions.
1. Why can't we override the property Name in CCustomer?
2. There is no Property for Address in CCustomer, yet we can code
objCustomer.Address = txtAddress.Text. Explain.
3. If you enter no data, but just press Add, the customer lives in Portland. But there is no reference to Portland in the Customer class.
Explain in light of the fact that constructors are not inherited.
4. SalesYTD is $78,000, but SalesYTD is a ReadOnly Property.
Where does it obtain its value?
What value(s) should we enter to verify that we never sell to minors (people under 18)? Does our logic work? Why or why not?
A1 : because you're trying to overrides a property from the base class Person that doesn't allow overriding name property .Simply to enable overriding of that method do this :
VB Code:
'in the base class Person
Public Overridable Property Name() As String
then it's solved .
A2 :objCustomer.Address = txtAddress.Text. Where is this piece of code ?
A3 :constructors are inheritable if you didn't override it with new constructor ..look at my code there ....
VB Code:
Public Sub New()
'************************************************ '* Person constructor
'************************************************Const c_strCity As String = "Portland"
Const c_strState As String = "OR"
State = c_strState
City = c_strCity
End Sub
A4 : It's taking the value from RecordSales sub.
Property SalesYTD() is returning the value of m_decSalesYTD which is the sum of decSales variable
m_decSalesYTD += decSales
I don't get your last question .