Question Class Inheritance

magpies18

Member
Joined
Oct 3, 2008
Messages
12
Programming Experience
Beginner
Hi i have problems coding for base class employee and its derived classes ss,os and cs. And salaries are calculated different for each category. For ss a basic pay and commission, os paid fixed monthly ans cs paid hourly. In a windows application...any help is very much appreciated
 
You gave very little information..

If it was me, I would have clsEmployee inherit clsPerson.. If salaries are calculated different, thats fine.. in clsEmployee you have a property 'role or type' which has values: ss,os and cs (use enum). You also have a property salary and commission.. inside this property you check the value of role or type and calculate the return value based on this.
 
Hi

I really glad u trying 2 help me out...actually im a beginner but have problems using base class and derived classes...The actual question was Given the base class Employee and its derived classes SalesStaff, OfficeStaff and ContractStaff. The salaries are computed differently for the categories of staff. The SalesStaff are paid a basic pay plus a commission based on their sales; the OfficeStaff are paid a fixed monthly salary; and the ContractStaff are paid hourly. So im required to write a program to compute and print the salaries for the different categories of staff. I already have the forms in windows application sorted out. I just need the coding in terms of idea on how to make it run.
 
No problem at all.

Have you managed to inherit employee class into your other classes yet? Its really simple.
VB.NET:
Public Class clsSalesStaff
  Inherits clsEmployee

  Public ReadOnly Property Salary() As Decimal
    ' Get info for calculating salary
    Return BasicPay + Commission
  End Property
End Class

Public Class clsOfficeStaff
  Inherits clsEmployee

  Public ReadOnly Property Salary() As Decimal
    ' Get info for calculating salary
    Return MonthlySalary
  End Property
End Class

Public Class clsContractStaff
  Inherits clsEmployee

  Public ReadOnly Property Salary() As Decimal
    ' Get info for calculating salary
    Return HourlyRate * HoursWorked
  End Property
End Class

This is a very general example... I don't know where / how you store your values (i.e HoursWorked, MonthlySalary etc)... but I hope this helps.
 
thanks

i actually store the values in notepad, which im ok with...since i have a main form which is called mainmenuform and there is button below called sales staff form known as sales_staff which will link me it so how and where do i put my coding for that...and again thanks for your time
 
hi

thanks again, how does the coding for clsEmployee go...im using notepad to store values so im ok with that...but how do link one form to another so that when i click in one form it shows the other?
 
ps if this is going to be a big system, notepad isn't going to cut it.

I would look into a database. MSAccess,MySQL,MSSql or Oracle are the main choices with different pros and cons (which would take too long for me to go into). There are whole websites dedicated to these.. MySQL is free and open source with a free .net connector, good choice... MSAccess would suit for a small/medium sized business.
 
Just think about it logically.... spend most of your time on the design. Have routines in your classes to load and save the data. Load the data when you load your form... you can use a binding source to bind the data to textboxes etc

good luck
 
o, i need to write the coding by today in about 4 hours so thanks anyway...i really appreciated ur help
Is this for school? If you're just doing this to pass a class then not diving into neat things like this, otherwise if this is something for your job or you are doing it as a hobbyist then after this assignment, I would suggest that you follow up on this thread when you get the time.
 

Latest posts

Back
Top