Question

JAVA - OOP inheritance help please I have a question, I have 4 classes. College, course,...

JAVA - OOP inheritance help please

I have a question,

I have 4 classes.

College, course, professor, professorInfo

College create new course(int x, int y, int z)

Professor is a Super class, professorInfo is the sub class of Professor.

Each time creating new course, more than 1 professor will be added to some kind of an Array.

--------------------------------------------------------------------

I cant figure out how to work around this. I know that I have to create a type of professor which contain all the professor info, and store it in an Array of type Professor. But I dont know how to do that.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Please find the answer below::

There will be four classes as below.

1)

Super class Professor.java

public class Professor {

}

2)
Base class ProfessorInfo.java

public class ProfessorInfo extends Professor {

}

3)
Course.java

Course class contains an array of Professor.

Course class will be having a method called addNewCourse, This method needs noOfProceffesors as required field to initialize the array of procefessor.

public class Course {
   Professor professors[];
  
   void addNewCourse(int x,int y,int noOfProfessors){
       professors = new Professor[noOfProfessors];
   }
  
}

4)

College.java that can call addNewCourse method of course to add number of courses. It will contains the list of course as an array as college can offer more than one course.

public class College {
   Course courses[];
}

Add a comment
Know the answer?
Add Answer to:
JAVA - OOP inheritance help please I have a question, I have 4 classes. College, course,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • write in java code. oop. i dont have its written code. i have its output in...

    write in java code. oop. i dont have its written code. i have its output in the thrid picture and how the inheritance works with the second picture. just need it in full written code and uni class will be. jus need you to write the whole code for me as its an extra question which i need for my preparation of my exam. add as you but it must be correct and similar to the question Inheritance Do the...

  • Purpose: The main goal of this assignment is to practice Object Oriented Programming by creating classes,...

    Purpose: The main goal of this assignment is to practice Object Oriented Programming by creating classes, writing methods, and creating inheritance type relationships. Task: Create a Java project using the IDE Write a program using Object Oriented Programming Plan a program where two classes inherit from a single class and theme it in a way that makes sense. Create a super class with a non-constructor method Create two sub classes with their own non-constructor methods and have them inherit from...

  • Can you please pick Automobile For this assignment. Java Programming Second Inheritance OOP assignment Outcome: Student...

    Can you please pick Automobile For this assignment. Java Programming Second Inheritance OOP assignment Outcome: Student will demonstrate the ability to use inheritance in Java programs. Program Specifications: Programming assignment: Classes and Inheritance You are to pick your own theme for a new Parent class. You can pick from one of the following: Person Automobile Animal Based on your choice: If you choose Person, you will create a subclass of Person called Student. If you choose Automobile, you will create...

  • java. do it on eclipse. the same way its instructed Second Inheritance OOP assignment Outcome: ...

    java. do it on eclipse. the same way its instructed Second Inheritance OOP assignment Outcome:  Student will demonstrate the ability to understand inheritance Program Specifications: Programming assignment: Classes and Inheritance You are to pick your own theme for a new Parent class. You can pick from one of the following:  Person  Automobile  Animal  If you choose Person, you will create a subclass of Person called Student.  If you choose Automobile, you will create a...

  • please answer correctly. Language/Type Java Inheritance polymorphism Assume that the following classes have been defined: public...

    please answer correctly. Language/Type Java Inheritance polymorphism Assume that the following classes have been defined: public class George extends Elaine ( public void method1() { print("George 1 "); public class Jerry { public void method10) { print("Jerry 1 "); public void method20 { print("Jerry 2 "); public String toString() { return "Jerry": public class Elaine extends Kramer public String toString() { return "Elaine " + super.toString(); public class Kramer extends Jerry public void method1() { super.method1(); print ("Kramer 1"); public...

  • Assignment Requirements I have also attached a Class Diagram that describes the hierarchy of the inheritance...

    Assignment Requirements I have also attached a Class Diagram that describes the hierarchy of the inheritance and interface behaviors . The link to the PDF of the diagram is below MotorVehical.pdf Minimize File Preview User Define Object Assignment: Create a Intellij Project. The Intellij project will contain three user defined classes. The project will test two of the User Define Classes by using the invoking each of their methods and printing the results. You are required to create three UML...

  • Hello! I have a problem in my code please I need help, I don't know How I can wright precondition, so I need help about assertion of pre_condition of peek. Java OOP Task is! Improve the circular a...

    Hello! I have a problem in my code please I need help, I don't know How I can wright precondition, so I need help about assertion of pre_condition of peek. Java OOP Task is! Improve the circular array implementation of the bounded queue by growing the elements array when the queue is full. Add assertions to check all preconditions of the methods of the bounded queue implementation. My code is! public class MessageQueue{ public MessageQueue(int capacity){ elements = new Message[capacity];...

  • Java assignment. There are five classes. You figure out the inheritance hierarchy. Animal, Dog, Brindle, Cat,...

    Java assignment. There are five classes. You figure out the inheritance hierarchy. Animal, Dog, Brindle, Cat, Driver Note: Brindle is a kind of dog that has stripes The following classes will have a makeSound method that displays the kind of sound the animal makes. Animal, Dog, Cat In the Brindle class, you will have an instance variable noOfStripes One of the classes should have an instance variable to hold the name of the animal Name One of the classes should...

  • In c# So far, you have created object-oriented code for individual classes. You have built objects...

    In c# So far, you have created object-oriented code for individual classes. You have built objects from these classes. Last week, you created a UML for new inherited classes and objects. Finally, you have used polymorphism. When you add abstraction to this mix, you have the “4 Pillars of OOP.” Now, you begin putting the pieces together to create larger object-oriented programs. Objectives for the project are: Create OO classes that contain inherited and polymorphic members Create abstracted classes and...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT