2 Replies - 1333 Views - Last Post: 08 December 2011 - 10:34 AM Rate Topic: -----

#1 MCarbone  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 19
  • Joined: 27-October 11

Is this going to work out in the end?

Posted 06 December 2011 - 06:13 AM

The Westfield Carpet Company has asked you to write an application that calculates the price of carpeting for rectangular rooms. To calculate the price, you multiply the area of the floor(width times length) by the price per square foot of carpet. For example, thearea of floor that is 12 feet long and 10 feet wide is 120 square feet. To cover that floor with carpet that costs $8 per square foot would cost $960 (12x10x8=960).
You should create a class named Rectangle with the following properties:
Width : A single
Length : A single
Area : A single
The Area property should be read-only. Provide a method named CalcArea that calculates widthxlength and stores the result in the Area property.
Next, create a class named Carpet with the following properties:
Color: A string
Style: A string
Price: A decimal

Here is the code I have so far...
Public Class Form1
    Public Class Rectangle
        'member variable
        Private sngWidth As Single      'holds width
        Private sngLength As Single     'holds height
        Private sngArea As Single       'holds area
        'constructor
        Public Sub New()
            sngWidth = CSng(String.Empty)
            sngLength = CSng(String.Empty)
            sngArea = CSng(String.Empty)
        End Sub
        'Width property procedure
        Public Property Width() As Single
            Get
                Return sngWidth
            End Get
            Set(value As Single)
                sngWidth = value
            End Set
        End Property

        'Height property procedure
        Public Property Length() As Single
            Get
                Return sngLength
            End Get
            Set(value As Single)
                sngLength = value
            End Set
        End Property

        'Area calculation is read-only
        Public ReadOnly Property Area() As Single
            Get
                'calculation for area
                Dim sngArea As Single
                'Determine area of room

            End Get
        End Property
    End Class
End Class




Am I even close to on the right track?? I am trying to take code from the book and manipulate it as I do NOT understand this AT all! :(
I have no clue how to do the CalcArea portion either. Any tips on that would be greatly appreciated! :)

Is This A Good Question/Topic? 0
  • +

Replies To: Is this going to work out in the end?

#2 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5476
  • View blog
  • Posts: 11,762
  • Joined: 02-June 10

Re: Is this going to work out in the end?

Posted 06 December 2011 - 08:38 AM

Area of a square is width times length

Beyond that, see FAQ 13 about talking to your instructor since you are totally lost.



FAQ (Frequently Asked Questions - Updated Nov 2011

Spoiler


Reminder to all: This is course homework. We do NOT provided completed code/solutions for homework. We can help the OP understand specific concepts they are having trouble with or specific errors they don't understand.

Of course they have to tell us the specific errors first, and not just "Can you help me with my homework, its due soon."

The stages of asking for homework help on a forum

This post has been edited by tlhIn`toq: 06 December 2011 - 08:39 AM

Was This Post Helpful? 0
  • +
  • -

#3 deery5000  Icon User is offline

  • D.I.C Addict

Reputation: 78
  • View blog
  • Posts: 966
  • Joined: 09-May 09

Re: Is this going to work out in the end?

Posted 08 December 2011 - 10:34 AM

Your on the right track :)

you have declared the functionalality of the width , length (set, get)

you simply do the same now for the area. The passge you have provided tells you how to do the calculations. You just need to add this to the function.


pass your values into the function and do the calculations and return the value.

eg dim getArea = new Rectangle
areaVal = getArea.area(your values to pass to function here for calculation)

areaVal now contains the result from your calculation returned from the area function

hope this helps
kevin
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1