Results 1 to 12 of 12

Thread: questions that I need help answering

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 2002
    Posts
    37

    Unhappy 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?
    Attached Files Attached Files

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083

    Re: questions that I need help answering

    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:
    1. 'in the base class Person
    2. 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:
    1. Public Sub New()
    2.         '************************************************        '*  Person constructor
    3.         '************************************************Const c_strCity As String = "Portland"
    4. Const c_strState As String = "OR"
    5.  
    6. State = c_strState
    7. City = c_strCity
    8. 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 .

  3. #3
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    this should answer your 3rd question :
    Attached Files Attached Files

  4. #4
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256
    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.
    Dont gain the world and lose your soul

  5. #5

    Thread Starter
    Member
    Join Date
    Nov 2002
    Posts
    37
    thank you guys!!

    I appreciate it!!

  6. #6
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    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.

  7. #7

    Thread Starter
    Member
    Join Date
    Nov 2002
    Posts
    37

    Talking

    Thank you gentlman......you helped me out tremendousley.....


  8. #8
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by nicky.1
    Thank you gentlman......you helped me out tremendousley.....
    Welcome any time.

  9. #9

    Thread Starter
    Member
    Join Date
    Nov 2002
    Posts
    37
    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

  10. #10
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    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 .

  11. #11

    Thread Starter
    Member
    Join Date
    Nov 2002
    Posts
    37
    I have a specific assignment that i am lost with.......

  12. #12

    Thread Starter
    Member
    Join Date
    Nov 2002
    Posts
    37
    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!!!


    Nicky
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width