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 box...so 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 Get Return _dblPrecentRaise End Get Set(ByVal value as Double) If value >= 0 then _dblPrecentRaise = value Else _dblPrecentRaise=0 End if End Set End property Public Property WorkerName () as String Get Return _strWorkerName End Get Set (ByVal value As String) _strWorkerName = value End Set End Property Public Property WorkerSalary () As Double Get Return _dblWorkerSalary End Get Set(ByVal. As Double) If value >0 Then _dblWorkerSalary=value Else _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 do..it 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

New Topic/Question
Reply




MultiQuote




|