Classes and Objects

Classes and Objects

Page 1 of 1

1 Replies - 852 Views - Last Post: 29 August 2010 - 10:10 PM Rate Topic: -----

#1 bell13   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 02-August 10

Classes and Objects

Posted 29 August 2010 - 09:04 PM

How are you doing? I currently need some assitiance on a code I am writing. It seems as though I am and the right direction..but I don't excatly know where I am going wrong.
The 1st part of the code required me to write a class definition for a class(Worker).
The class should include Private variables and Property procedures for a worker object's name and salary.
The salary may contain a decimal place.
The class should also contain two constructors:a default and a parameterized.

The second part for the code indicates that I need add a method named GetNewSalary to the Worker class.
The method should calculate a Worker objects new salary, which is based on a raise percentage provided by the application using the object.
Before calculating the new salary, the method should verify that the raise percentage is greater than or equal to zero. If the raise percentage is less than zero the method should assign the number zero as the new salary
There are three text boxes which allows the user to enter the employees name current salary and raise percentage....the calculate button will display the new salary in the new salary label far here is what I have for the worker class.

The Class for the code had to be written from scratch. Can you please look over the class code and see if I need to chang anything....that will allow the program to run.
Public Class worker
Private _dblPrecentRaise as Double
Private _strWorkerName as String
Private _dblWorkerSalary as Double

Public Property PrecentRaise() as double
Return _dblPrecentRaise
End Get
Set(ByVal value as Double)

If value >= 0 then _dblPrecentRaise = value
End if
End Set
End property

Public Property WorkerName () as String
Return _strWorkerName
End Get

Set (ByVal value As String)
_strWorkerName = value
End Set
End Property

Public Property WorkerSalary () As Double
	Return _dblWorkerSalary
End Get

Set(ByVal. As Double)
	If value >0 Then
	_dblWorkerSalary = 0
	End If
End Set
End Property

'Default constructor

Public Sub New ()
	_dblWorkerSalary =0
	_strWorkerName = String.Empty
	_dblPrecentRaise =0
End Sub

'Parameterized constructor

Public Sub New(ByVal dblWorkerSalary As Double, ByVal strWorkerName As String, _
ByVal dblPrecentRaise As Double)

WorkerSalary = dblWorkerSalary
WorkerName = strWorkerName

End Sub

Public Function GetNewSalary (ByVal dblRaise As Double, _
							     ByVal dblOldSalary As Double, _
							     ByVal dblPrecentRaise As Double) As Double
Return (dblPrecentRaise * dblOldSalary)

End Function
End Class

If you can help please will be greatly appreciated...Thanks alot

This post has been edited by bell13: 30 August 2010 - 06:48 AM
Reason for edit:: Please use the code tags when posting code

Is This A Good Question/Topic? 0
  • +

Replies To: Classes and Objects

#2 Martyr2   User is online

  • Programming Theoretician
  • member icon

Reputation: 5226
  • View blog
  • Posts: 14,006
  • Joined: 18-April 07

Re: Classes and Objects

Posted 29 August 2010 - 10:10 PM

What is it that you need help with? We are not going to do the homework for you. You have to tell us what you are having trouble understanding or what is not working for you.

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1