课程: Java Object-Oriented Programming
今天就学习课程吧!
今天就开通帐号,24,600 门业界名师课程任您挑!
Solution: Build an employee class
(upbeat music) - [Instructor] Let's represent an employee, in Java, with a class. We'll create a new class, call it employee, and give it the appropriate attributes. We'll say it has a name that's a string, a location that's also a string, a double salary, and an age that's an int. These will all be non-static attributes, because they vary based on each employee instance. One might say, all employees are based in a single location, in which case the location might be static. Another option is to make an enum for the location, so there are only a set of places where a given employee might work from. It's all up to you on how you want to represent an employee object in code. To create employees, we'll need a constructor. We'll write Employee, and we'll want to create a custom employee with given name, location, salary, and age attributes, so we'll need to pass those in as parameters, then we'll set up our employee.…
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。
内容
-
-
-
(已锁定)
Using classes as blueprints4 分钟
-
(已锁定)
Building objects with a constructor2 分钟 48 秒
-
(已锁定)
Using concrete instances for application logic4 分钟 32 秒
-
(已锁定)
Understanding the difference between class and instance members4 分钟 54 秒
-
(已锁定)
Exploring a built-in Java class4 分钟 5 秒
-
(已锁定)
Challenge: Build an employee class1 分钟 8 秒
-
(已锁定)
Solution: Build an employee class3 分钟 11 秒
-
(已锁定)
-
-
-
-
-