1. Trang chủ
  2. » Kỹ Năng Mềm

OOP lab3 Kỹ năng lập trình hướng đối tượng

11 61 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

nghiên cứu khoa họcLập trình hướng đối tượng Opp.Tài liệu Ea về hệ thống nhúng và lập trình hướng đối trượng giúp bạn học tốt opp. Ra đời trong hoàn cảnh hệ thống Phòng khám tại Bình Dương chưa đáp ứng được đầy đủ nhu cầu về số lượng cũng như chất lượng khám chữa bệnh, Công ty cổ phần Dịch vụ y tế Toàn Nhân Ái mong muốn được chung vai gánh vác, chia sẻ gánh nặng với xã hội trong việc điều trị bệnh và chăm sóc sức khỏe cho cộng đồng. Không chỉ nhằm góp phần giảm tải cho các bệnh viện công, chúng tôi còn hướng tới việc cung cấp dịch vụ khám, tầm soát và điều trị bệnh toàn diện đạt chuẩn quốc tế với đội ngũ bác sỹ giỏi trong nước. Công ty cổ phần Dịch vụ y tế Toàn Nhân Ái mong muốn trở thành một trong những bệnh viện khám chữa bệnh hàng đầu trong cả nước, địa chỉ khám chữa bệnh tin cậy cho người dân trong nước nói chung, và các tỉnh phía Bắc nói riêng. Chúng tôi chú trọng vào việc đầu tư trang bị y tế hiện đại tiêu chuẩn quốc tế, kết hợp với kiến thức của đội ngũ bác sỹ giỏi nhằm đưa đến kết quả khám bệnh chính xác nhất và điều trị bệnh tốt nhất cho người dân. Đồng thời, tạo một môi trường y tế an toàn, thân thiện, chất lượng cao hơn cho tất cả mọi người. Việc lựa chọn phát triển khoa mũi nhọn của Công ty cổ phần Dịch vụ y tế Toàn Nhân Ái theo hai tiêu chí: thứ nhất là đáp ứng nhu cầu của nhiều người dân nhất như Khoa khám bệnh, Khoa chẩn đoán hình ảnh, Khoa xét nghiệm, Khoa Sản, Khoa ngoại, đã phần nào thể hiện quyết tâm của Bệnh viện vươn đến mục tiêu của mình trên con đường cống hiến cho cộng đồng, cho xã hội.

Thu Dau Mot University Object Oriented Programming HANDS-ON #3: INHERITANCE Objective   Understand inheritance in OOP Implement inheritance in OOP Literature   Inheritance can be defined as the process where one class acquires the properties (methods and fields) of another With the use of inheritance, the information is made manageable in a hierarchical order The class which inherits the properties of other class is known as subclass (derived class, child class) and class whose properties are inherited is known as superclass (base class, parent class) 2.1 Keyword “extends”  The extends keyword is used to inherit the variables and method of a class (except private variables and private methods) public class Super { /* */ } public class Sub extends Super { /* */ } 2.2 Keyword “super”   The super keyword in java is a reference variable which is used to refer immediate parent class object The usage of super keyword: o To refer parent class instance variable o To invoke parent class method o The super() can be used to invoke parent class constructor If a class is inheriting the properties of another class And if the members of the subclass have the names which same as the superclass, to differentiate these variables we use super keyword as follows: o For variable: super.variableName o For method: super.methodName() Thu Dau Mot University Object Oriented Programming Example Person.java public class Person { private String name; private String address; public Person() {} public Person(String name, String address) { this.name = name; this.address = address; } public Person(Person person) { this.name = person.name; this.address = person.address; Thu Dau Mot University Object Oriented Programming } public String getName() { return this.name; } public void setName(String name) { this.name = name; } public String getAddress() { return this.address; } public void setAddress(String address) { this.address = address; } @Override public String toString() { return "Person{" + "name='" + name + "\'" + ", address='" + address + "\'" + "}"; } } Teacher.java public class Teacher extends Person { private String subject; public Teacher() {} public Teacher(String name, String address, String subject) { super(name, address); this.subject = subject; } public String getSubject() { return this.subject; } public void setSubject(String subject) { this.subject = subject; } } Thu Dau Mot University Object Oriented Programming Hands-on 4.1 Lab 3.1: Implement Java classes based on following diagram (1.5 pts): Thu Dau Mot University Object Oriented Programming Circle.java public class Circle { private double radius; private String color; public Circle() {} public Circle(double radius) { } public Circle(double radius, String color) { } public double getRadius() { return this.radius; } public void setRadius(double radius) { this.radius = radius; } public String getColor() { return this.color; } public void setColor(String color) { this.color = color; } public double getArea() { } @Override public String toString() { } } Cylinder.java public class Cylinder extends Circle { private double height; public Cylinder() {} public Cylinder(double radius) { Thu Dau Mot University Object Oriented Programming } public Cylinder(double radius, double height) { } public Cylinder(double radius, double height, String color) { } public double getHeight() { return this.height; } public void setHeight(double height) { this.height = height; } public double getVolume() { } @Override public String toString() { } } Thu Dau Mot University Object Oriented Programming 4.2 Lab 3.2: Implement Java classes based on following diagram (1.5 pts):  See example in section Thu Dau Mot University Object Oriented Programming 4.3 Lab 3.3: Implement Java classes based on following diagram (1.5 pts): Thu Dau Mot University Object Oriented Programming 4.4 Lab 3.4: Implement Java classes based on following diagram (1.5 pts): Thu Dau Mot University Object Oriented Programming 4.5 Lab 3.5: Implement the Employee class to store the information of employees in the manufacturing company ABC (2 pts)    Attributes: o id: String o fullName: String o yearJoined: int o coefficientsSalary: double o numDaysOff: int (number of days off in the month) Constructors: o Constructor with no parameter Employee() (ID = 0, fullName = ””, yearJoined = 2020, coefficientsSalar = 1.0, numDaysOff = 0) o Constructor with parameter Employee(ID: String, fullName: String, coefficientsSalary: double) (yearJoined = 2020, numDaysOff = 0) o Constructor with full parameters Methods: o public double getSenioritySalary(): calculating seniority salary of employees: Know that if an employee works for years or more, the seniority salary is calculated according to the following formula: seniority salary = years of work * basic salary / 100 o public String considerEmulation(): write a method to evaluate employee emulation If the number of holidays

Ngày đăng: 19/03/2022, 11:15

Xem thêm:

TỪ KHÓA LIÊN QUAN

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN

w