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?
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 bjCustomer.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 .
2. There is no Property for Address in CCustomer, yet we can code objCustomer.Address = txtAddress.Text. Explain.
This property is declared public in the base class Person, so it is inherited by the Customer class.
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.
Constructors are not inherited but properties are. If you look at the Person class, you will see that in constructor Portland is assigned to an instance variable, then it is assigned to the property City. Now in the Customer class, the constructor calls the base constructor of Person which does the assignment. So the Customer class is getting Portland from the inherited City property which is set when a new Customer object is created.
Originally posted by DevGrp This property is declared public in the base class Person, so it is inherited by the Customer class.
Constructors are not inherited but properties are. If you look at the Person class, you will see that in constructor Portland is assigned to an instance variable, then it is assigned to the property City. Now in the Customer class, the constructor calls the base constructor of Person which does the assignment. So the Customer class is getting Portland from the inherited City property which is set when a new Customer object is created.
little correction , DevGrp is right . Constructors are not inherited but a copy would be required if it's parameterized.
Pirate,
I am having a very difficult time in this programmng class and it is the last class I need to take to finish my CIS degree. I have a few more assignments and I was hoping that you could help me, not do them, just maybe help me understand how to do them as I am lost. My first teacher wasnt so bad but this new guy is an Anal ass......and as it is I am getting a D in the class now. I have 6 more weeks until this term is over and this class. If you cant help do you know of someone who can? I am desperate as I dont want to drop this class and start all over to be in the same place next time.
Originally posted by nicky.1 Pirate,
I am having a very difficult time in this programmng class and it is the last class I need to take to finish my CIS degree. I have a few more assignments and I was hoping that you could help me, not do them, just maybe help me understand how to do them as I am lost. My first teacher wasnt so bad but this new guy is an Anal ass......and as it is I am getting a D in the class now. I have 6 more weeks until this term is over and this class. If you cant help do you know of someone who can? I am desperate as I dont want to drop this class and start all over to be in the same place next time.
Thank You
N
I'll be happy to help anyone as much as I can .
Do you have specific question ? if I couldn't solve it , maybe other guys will try to help .
Hello anyone and everyone.......I have a midterm coming up and I am clueless as to what I am doing half the time, failing as it is...so I am asking if anyone would be willing to look at this review and give me some examples for the examples that are given? I am really trying to grasp this but getting some input from actual programmers might be a little more helpful. Thank you in advance!!!