Click here to Skip to main content
15,888,521 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Write a console app that declares two classes Employee (base) and (10)
Receptionist (derived).
• Include within Employee class private members: emp_name, emp_lastname,
emp_id,emp_physicaladdress and overridable public member Allowance()
which returns total amount of allowance for each employee which is a sum of
R2500 for house per month, R1000 for car per month.
• Allowance() takes three arguments which is houseAllowance, carAllowance
and allowanceTotal.
• Include in Receptionist class private members: rec_workinghours, rec_salary,
constant clothingAllowance and public member Allowance() which returns
allowance specifically for the receptionist.
• Receptionist has additional allowance of clothing which is R500 per month
• Derive Receptionist class from Employee class.
• Display respective details about one employee and one receptionist refer to
the table:
                 Employee           Receptionist
emp_name         Given              Mahlatse
emp_l.name       Romeo              Remeo
emp_id           11111              22222
emp_p.address    207 Ext 5          203 Ext 5
Emp_allowance    3500               4000
rec_w.hours                         8
rec_salary                          20000


What I have tried:

VB
Module Module1

    Sub Main()

        Console.WriteLine("Enter employee name: ")
        Dim emp_name As String = (Console.ReadLine())
        Dim Em = New Employee()
        Em.emp_name = emp_name

        Console.WriteLine("Enter employee Last Name:")
        Dim emp_LastName As String = (Console.ReadLine())
        Em.emp_lastname = emp_LastName

        Console.WriteLine("Enter employee ID: ")
        Dim emp_ID As Integer = (Console.ReadLine())
        Em.emp_ID = emp_ID

        Console.WriteLine("Enter your phisical adress:")
        Dim emp_Address As String = (Console.ReadLine())
        Em.emp_physicaladdress = emp_Address

        Console.WriteLine("Enter employee Allowance total: ")
        Dim emp_Allowance As Integer = (Console.ReadLine())
        Em.Emp_allowance = emp_Allowance

        Console.WriteLine("Enter Receptionist Name: ")
        Dim Rec_Name As String = (Console.ReadLine())
        Em.rec_name = Rec_Name

        Console.WriteLine("Enter Receptionist Surname: ")
        Dim Rec_surname As String = (Console.ReadLine())
        Em.rec_Surname = Rec_surname

        Console.WriteLine("Enter Receptionist ID: ")
        Dim Rec_ID As Integer = (Console.ReadLine())
        Em.rec_ID = Rec_ID

        Console.WriteLine("Enter Receptionist physical adress: ")
        Dim rec_Adress As String = (Console.ReadLine())
        Em.rec_address = rec_Adress

        Console.WriteLine("Enter receptionist Allowance total")
        Dim rec_allowance As Integer = Convert.ToInt32(Console.ReadLine())
        Em.rec_allowance = rec_allowance
        Dim hour, salary As Integer
        hour = 8
        salary = 2000

        Console.WriteLine("                   " + "Employee" + "                          " + "Receptionist")
        Console.WriteLine("emp_name" + "            " + emp_name + "                     " + Rec_Name)
        Console.WriteLine("emp_l.name" + "          " + emp_LastName + "                    " + Rec_surname)
        Console.WriteLine("emp_id" + "              " + Convert.ToString(emp_ID) + "        " + Convert.ToString(Rec_ID))
        Console.WriteLine("emp_p.adress" + "        " + emp_Address + "                     " + rec_Adress)
        Console.WriteLine("emp_allowance" + "       " + Convert.ToString(emp_Allowance) + " " + Convert.ToString(rec_allowance))
        Console.WriteLine("emp_W.hours" + "         " + Convert.ToString(hour))
        Console.WriteLine("salary" + "              " + Convert.ToString(salary))




        Console.ReadLine()

        End
    End Sub

End Module
Posted
Updated 15-Nov-20 21:20pm
v2
Comments
Dave Kreskowiak 15-Nov-20 23:06pm    
You never asked a question or described a problem you're having.
Maciej Los 16-Nov-20 3:09am    
Where is the definition of Employee and Receptionist class?

1 solution

Read the question again. You appear to have created the Employee class, but there is no sign of a Receptionist class which is specifically required.
And it needs to be derived from Employee, since a Receptionist is also an Employee.

When you have created both classes - and tested that they work - add a method to the base class that request the Employee data and fills it in, then override it in the Receptionist class to call the base method and then add the Receptionist specific data.

Construct one instance of each class, and fill the data in.
Then use that class data to display the data the question asks for.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900