‫Welcome back.
‫I hope you try to finish this challenge where you had to create several classes and subclasses or several
‫deriving classes.
‫And yeah, let's just go ahead and start with it.
‫So let's create a new class called Employee.
‫And this employee should have several information.
‫First of all the names so I'm just gonna go ahead and prop and it's going to be a string property with
‫name.
‫Then we have another one, prop string, first name.
‫And the third one is a property called celery.
‫So now we have those three properties and we can go ahead and create a.
‫Constructor, public employee, and that one takes in a name, a first name and a salary.
‫And of course, we need to set those.
‫So this dot name is going to be named this.
‫The first name is going to be first name.
‫And this dot salary is going to be salary.
‫All right, so that's our constructor.
‫And then.
‫Our employee should have methods called work and POS.
‫So let's create those public void work.
‫And this should just write somewhere like I am working.
‫And then one that is a void called pause, which is just going to write something like I am having a
‫break.
‫All right, so that's pretty much our employee.
‫And now we want to inherit from that employee and we want to go ahead and create a new class called
‫Boss.
‫So this is going to be both actually.
‫Let's change that.
‫Let's just delete this class and create a new one.
‫We could have renamed it, but creating a new one is more convenient actually boss like that.
‫And now that boss should have an own property.
‫As stated here.
‫So let's go back.
‫Created your own class boss with a property called Company Car and the method lead.
‫So let's create those property and this one should be a string and I'm going to call it company car.
‫And then we have the method public void lead.
‫And this one's just going to say something like I'm the boss or something like that.
‫CW Boss.
‫So great English grammar in here.
‫I'm boss.
‫And now we should go ahead and create another driving class of employees called trainees or trainee
‫with the properties working hours and school hours and the method learn.
‫So let's just do that.
‫Let's create a new class called.
‫Trainee.
‫And that trainee, by the way, the boss didn't derive from employee, so should just add that employee.
‫The same goes for our trainee.
‫It also derives from employee.
‫And now, as you see, as it does not have a.
‫As we don't have an empty.
‫Constructor in here.
‫It's complaining.
‫So I'm going to create an empty and structure, which is just going to say the name is going to default
‫as Dennis, then the first name is going to be defaulted as actually the first name is Dennis.
‫The last name should be pun Utah in my case.
‫And then we have the salary, which is just going to be let's keep it simple, 50 grand, not very accurate,
‫and we don't even talk about the currency.
‫All right.
‫So now if we say that, you see the error disappears because if I don't have that.
‫So just a second, let's get rid of it.
‫It will or it will be unhappy here.
‫So you say there is no argument given that corresponds to the required formal parameter name of employee
‫employee string string int.
‫So either that or we have to implement a constructor in the boss class.
‫Which I think we should still do.
‫So let's do that, because if we create a boss, we want to inform or we want to add the information
‫about this company car.
‫So let's create a public boss, which will take a string called company car.
‫Company car, then a string called name, string called first name and an integer called celery
‫root.
‫And now when here we just say something like this dot company car is equal to comp per ne car.
‫Now all of the other ones are missing.
‫And we can, of course, go ahead and say something like this dot name is equal to name, but we can
‫even make it simpler by using something called the base.
‫So we're using base name, first name and salary.
‫So what that does is it simply uses the approach that we had here.
‫So this one here, so it's using this constructor for us.
‫So we don't have to write all of that initialization in here.
‫All right, before we do anything else, let's test that.
‫So let's create an employee.
‫Or actually, let's create a boss.
‫So let's go ahead with an employee.
‫So employee is going to be Michael
‫my co and he is a new employee and now we could go ahead like that.
‫So that will be Dennis.
‫So it will just take this constructor here, but as I prefer to inform about the real Michael, so it's
‫going to be Michael Miller and his salary is going to be 40,000.
‫And now we can, of course, go ahead and call methods of Michael.
‫Michael.
‫And we had well, he should work, so please go ahead and work.
‫And Michael, go ahead and make a pass.
‫And then finally console Todd Reed key in order to keep the console open.
‫So let's test that.
‫And we are.
‫So first he's working and then he's having a break and that's great.
‫Good guy, Michael.
‫Now we can go ahead and create a boss.
‫So let's go ahead and say boss and I'm going to call him.
‫Chuck Norris is going to be a new boss called.
‫Well, he needs a company car.
‫What's it's going to be for Ferrari, then a name.
‫And this will be Norris.
‫Then the first name will be Chuck and the salary is going to be over 9000.
‫So just a very high value and it's actually not accepting that value.
‫So that was too much for an integer to bear.
‫So that's a lot of money that Chuck is making and now we can go ahead and make him lead.
‫So let's Chuck Norris be our leader and he's going to lead.
‫So let's see what he says.
‫And he says, I'm boss.
‫And of course, we can go ahead and add some more information about what he's saying.
‫My name is.
‫And then we just use something like his name and you could even add some more information about his
‫salary, all of those kind of things.
‫So that was not part of the exercise, but I'm just adding it here.
‫So we have a little more information about this guy, and I'm going to start with the first name and
‫then I'm going to go ahead with the last name or actually the name.
‫And as you can see, I can use them even though I haven't created those properties in my boss because
‫I'm inheriting them from employee.
‫And now if we run it again on boss, my name is Chuck Norris and that's awesome.
‫So Chuck Norris is our boss.
‫Now, our trainee needs also to do something, so he should have his own properties, which is for one,
‫his working hours, working hours, and another one which is going to be his study hours or school hours.
‫So it should be the study hours in the sense of him studying at home.
‫But actually, I'm not sure whether you are aware about the training system in Germany.
‫You have a three year training system in which you learn a job and it's similar to well, it's not really
‫similar to the college, but that's pretty much like after ten years of school, you go there, you
‫go to this, you study a trainee job, and you do that for three years.
‫And afterwards, you're an expert, not an expert, but you are well educated to do the job quite well.
‫So you have like 60% of working time or even 80% of working time and then one day of school.
‫So you go to school in order to learn more detailed, important information about the task at hand.
‫And that's something that works quite well for Germany.
‫So we don't need to everybody to go to university in order to get a good job or everybody to go to college
‫to get a good job.
‫So this is quite an alternative there.
‫All right.
‫So just a little side note and now let's go ahead and create a trainee constructor and it will need
‫the working hours, then the school hours,
‫a name, a first name, string, first name, color like that, I think like this and int salary.
‫And now here we're using base as well.
‫And if you didn't do that, that's totally fine.
‫No worries.
‫It's just for you to know that you can do that.
‫So name, first name and salary.
‫I'm just going to take the ones from our base class and now I just need to assign the working hours.
‫And actually here I want to have this start working hours, which will be our working hours and then
‫this dot school hours, which will be our school hours and that's it, right?
‫Name, first name and salary are from the base class anyways.
‫And now we need to methods learn.
‫And what was it.
‫Learn and work and now work.
‫The trainee should work slightly differently than the.
‫Boss or the employee.
‫So we learn.
‫And here we just write something like.
‫CW I'm learning for so many hours like this and it will be the learning hours or school hours.
‫Like that.
‫And now the last method will be public void work.
‫And now this one should actually override our employee method console, dot, right line.
‫I work for 0 hours.
‫And by zero.
‫I don't mean zero.
‫I mean the working hours.
‫So now if you see that it says hides inherited member employee work used use new key word if hiding
‫was intended and that's something that we will cover in detail in the next chapter where we're talking
‫about polymorphism.
‫But now let's just create a new employee and this time it's going to be a trainee employee.
‫So I'm going to call her Michelle and she's going to be the new trainee.
‫Michelle, actually, she needs working hours.
‫Let's say she's working for 32 hours a week.
‫Then she goes to school for 8 hours a week.
‫Her name is Michelle Gardener.
‫So.
‫Michelle and her salary is something like 10,000 a year.
‫All right.
‫So now let's go ahead and ask Michelle about her studying.
‫So how is that going?
‫And then Michelle, the work.
‫Now let's run it and you will see what's gonna happen.
‫And it says, I'm learning for 8 hours and I work for 32 hours.
‫Well, we have overridden it, and we just used the exact same method.
‫So work.
‫Same name.
‫This one was not virtual and we overrode it.
‫And here it's complaining.
‫Or it's not really complaining, but it says that there is something not perfectly right.
‫So that's perfect because it helps us to go to the next chapter where we talk about polymorphism, about
‫overriding methods even further, because so far we've only used one approach, but there are multiple
‫ones.
‫So if I, for example, create a public new void work that will go ahead and create a new method for
‫me.
‫And well, in our case it does the same thing.
‫But when it comes to polymorphism, this is going to have a huge impact onto our our program.
‫So I hope you manage to build that.
‫And it was just a different exercise, just a new exercise, another one for you to test again, whether
‫you can handle that, whether you can create subclasses and just to get a better understanding of how
‫classes or the base classes and deriving classes work together and how to build them and stuff like
‫that.
‫Great.
‫So see you in the next chapter where we're going to go into polymorphism.