Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA Add a method to the lecturer object that changes the students marks. This method should be defined to take a student object and a

JAVA

Add a method to the lecturer object that changes the students marks. This method should be defined to take a student object and a number as arguments.

Write a program that creates one student and lecturer object. The program should invoke the lecturer objects method to change the students marks. The program should also display the details of the student object, including the students new marks.

Person.java

public class Person {

private String ID;

private String name;

private String gender;

public Person(String ID, String name, String gender) {

this.ID = ID;

this.name = name;

this.gender = gender;

}

public String getID() {

return ID;

}

public void setID(String iD) {

ID = iD;

}

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

public String getGender() {

return gender;

}

public void setGender(String gender) {

this.gender = gender;

}

@Override

public String toString() {

return "Person [ID=" + ID + ", name=" + name + ", gender=" + gender + ", getID()=" + getID() + ", getName()="

+ getName() + ", getGender()=" + getGender() + "]";

}

}

Student.java

public class Student extends Person{

private int marks;

public Student(String ID, String name, String gender, int marks) {

super(ID, name, gender);

this.marks = marks;

}

public int getMarks() {

return marks;

}

public void setMarks(int marks) {

this.marks = marks;

}

}

Lecturer.java

public class Lecturer extends Person{

public Lecturer(String ID, String name, String gender){

super(ID, name, gender);

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advanced Database Systems For Integration Of Media And User Environments 98

Authors: Yahiko Kambayashi, Akifumi Makinouchi, Shunsuke Uemura, Katsumi Tanaka, Yoshifumi Masunaga

1st Edition

9810234368, 978-9810234362

More Books

Students also viewed these Databases questions

Question

Discuss the goals of financial management.

Answered: 1 week ago