In your main method, create a student object and an instructor object.

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

In your main method, create a student object and an instructor object.

Post by answerhappygod »

In your main method, create a student object and an instructorobject.
In Your Main Method Create A Student Object And An Instructor Object 1
In Your Main Method Create A Student Object And An Instructor Object 1 (61.67 KiB) Viewed 66 times
Suppose we are designing a simple college record-keeping program that has records for students and faculty. There is a natural hierarchy for grouping these record types: They are all records of people (inheriting from class Person). Students. They have the following properties: o Name, Student Number, Major, and Level (freshman, sophomore, junior, senior) ● Instructors. Instructors have the following properties: o Name, ID, Salary. However, the salary is a property in the job class (can be found below: In your main method, create a student object and an instructor object. public class Job { private String role; private long salary; private int id; public String getRole(){ return role; } public void setRole(String role){ this.role = role; } public long getSalary(){ return salary; } public void setSalary(long salary){ this.salary = salary; public int getId(){
public class Person { //composition has-a relationship private Job job; public Person () { } this.job=new Job(); } public long getSalary(){ job.setSalary(1000L); } return job.getSalary(); public class TestPerson { public static void main(String[] args) { Person person = new Person(); long salary = person.getSalary();
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply