Question

write java program and for the following (you can add more classes as you see necessary)...

write java program and for the following

(you can add more classes as you see necessary) as follows:
a class called Coursewith courseCode, courseName,and creditHours;
a superclass called FacultyMemberwith FacultyID, firstName, lastName, academicRank,
and academicSpecialization;
a course Convener subclass inherits from the FacultyMember class with specific member variables representing the coursesand members (Lecturers andTAs) whom
he/she is responsible of; Lecturers andTAsare also subclasses that inherit from FacultyMemberclass with some specific member variables (i.e., maximumNumberOfCourses, quotaOfCreditHoursthey can take, and assignedCourses).

Create a project called TaibahCSand implement your class diagram that must include: Course, FacultyMember, Convener, Lecturers, andTAs.
Declare some overloaded constructors with parameters for all classes, and some appropriate methods as you suggest.

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

CODE FOR ABOVE PROBLEM

Course.java

package teaching;

public class Course {
  
   String courseCode;
   String courseName;
   int creditHours;
   //constructor for course
   public Course(String courseCode, String courseName, int creditHours) {
       this.courseCode = courseCode;
       this.courseName = courseName;
       this.creditHours = creditHours;
   }
  
   //toString method which return the course object in string form
   public String toString() {
       return "Course [" + courseCode +" " + courseName + creditHours + "]";
   }
}

FacultyMember.java Code

package teaching;

public class FacultyMember {
  
   String facultyId;
   String firstName;
   String lastName;
   int acadamicRank;
   String acadamicSpecialization;
   //constructor for facultMember class
   public FacultyMember(String facultyId, String firstName, String lastName, int acadamicRank,
           String acadamicSpecialization) {
       this.facultyId = facultyId;
       this.firstName = firstName;
       this.lastName = lastName;
       this.acadamicRank = acadamicRank;
       this.acadamicSpecialization = acadamicSpecialization;
   }
   @Override
   public String toString() {
       return "FacultyMember ["+ facultyId +" " + firstName +" "+ lastName
               +" "+ acadamicRank +" "+ acadamicSpecialization + "]";
   }

}

Lecturer.java Code

package teaching;

import java.util.ArrayList;

public class Lecturers extends FacultyMember
{


   int maxNoOfCourses;
   int quotaOfCreditHours;
   int currentCourses=0;
   ArrayList<Course>assignedCourse;//to hold assigned courses of lecturer
   public Lecturers(String facultyId, String firstName, String lastName, int acadamicRank,
           String acadamicSpecialization, int maxNoOfCourses, int quotaOfCreditHours
           ,ArrayList<Course>assignedCourse) {
       super(facultyId, firstName, lastName, acadamicRank, acadamicSpecialization);
       this.maxNoOfCourses = maxNoOfCourses;
       this.quotaOfCreditHours = quotaOfCreditHours;
       this.assignedCourse = assignedCourse;
   }
  
   public void addCourse(Course course)
   {
       if(currentCourses==maxNoOfCourses)
       {
           System.out.println("Maximum No of Courses is reached");
       }
       else
       {
           assignedCourse.add(course);
           currentCourses++;
       }
   }
   public String toString()
   {
       return "Lecturer[ "+maxNoOfCourses+" "+quotaOfCreditHours+" Assigned Courses:\n"+assignedCourse.toString();
   }
}


TA.java Code

package teaching;

import java.util.ArrayList;

public class TA extends FacultyMember
{

   int maxNoOfCourses;
   int quotaOfCreditHours;
   int currentCourses=0;
   ArrayList<Course>assignedCourse;//to hold assigned courses of lecturer
   public TA(String facultyId, String firstName, String lastName, int acadamicRank,
           String acadamicSpecialization, int maxNoOfCourses, int quotaOfCreditHours
           ,ArrayList<Course>assignedCourse) {
       super(facultyId, firstName, lastName, acadamicRank, acadamicSpecialization);
       this.maxNoOfCourses = maxNoOfCourses;
       this.quotaOfCreditHours = quotaOfCreditHours;
       this.assignedCourse = assignedCourse;
   }
  
   public void addCourse(Course course)
   {
       if(currentCourses==maxNoOfCourses)
       {
           System.out.println("Maximum No of Courses is reached");
       }
       else
       {
           assignedCourse.add(course);
           currentCourses++;
       }
   }
   public String toString()
   {
       return "TA[ "+maxNoOfCourses+" "+quotaOfCreditHours+" Assigned Courses:\n"+assignedCourse.toString();
   }
}

Conviner.java Code

package teaching;

public class Convener
{
   Course course;
   FacultyMember member;//member can be either TA or Lecturers
   public Convener(Course course, FacultyMember member) {
       this.course = course;
       this.member = member;
   }

  

   @Override
   public String toString() {
       return "Convener [" + course +" " + member+"]" ;
   }
}

TaibahCS.java Code

package teaching;

import java.util.ArrayList;

public class TaibahCS {

   public static void main(String[] args) {
      
       ArrayList<Course>list1=new ArrayList<Course>();
       list1.add(new Course("Java101","Object Oriented",25));
       list1.add(new Course("C102","C Programming",17));
       list1.add(new Course("DLD53","Digital Logic and Design",15));
       list1.add(new Course("OS103","Operating System",10));
       //creating object of TA
       FacultyMember ta=new TA("TAId1","Sudeepthi","Maruvada",34,"CSE",5,5,list1);
      
       System.out.println(ta);
      
       ArrayList<Course>list2=new ArrayList<Course>();
       list2.add(new Course("DBMS201","DataBase Management",15));
       list2.add(new Course("CNS203","Cryptography",18));
       list2.add(new Course("SE204","Software Engineering",20));
       //creating object of Lecturer
       Lecturers lecturer=new Lecturers("LecId1","Kowlutla","Mangali",2,"CSE",3,5,list2);
      
       System.out.println(lecturer);
      
       //passing above two objects to Convener class
      
       Convener convener=new Convener(new Course("Java101","Object Oriented",25),ta);
       System.out.println(convener);

   }

}

OUTPUT:

TA[ 5 5 Assigned Courses:
[Course [Java101 Object Oriented25], Course [C102 C Programming17], Course [DLD53 Digital Logic and Design15], Course [OS103 Operating System10]]
Lecturer[ 3 5 Assigned Courses:
[Course [DBMS201 DataBase Management15], Course [CNS203 Cryptography18], Course [SE204 Software Engineering20]]
Convener [Course [Java101 Object Oriented25] TA[ 5 5 Assigned Courses:
[Course [Java101 Object Oriented25], Course [C102 C Programming17], Course [DLD53 Digital Logic and Design15], Course [OS103 Operating System10]]]

Add a comment
Know the answer?
Add Answer to:
write java program and for the following (you can add more classes as you see necessary)...
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
  • ****Please read the following requirements and use java language w/ comments**** ****Can make this a multi...

    ****Please read the following requirements and use java language w/ comments**** ****Can make this a multi part question if needed**** Project requires a base class, a derived subclass, and an interactive driver (class with a main) that allows the user to utilize and manipulate the classes created. You may select one super class from the following:               Superclass                                    Example subclasses Ship class                                a) battleship, tugboat, icebreaker Person class                           b) manager, salaryworker, hourlyworker Aircraft class                         c) Learjet, cargoplane,...

  • In Java Which of the following statements declares Salaried as a subclass of payType? Public class...

    In Java Which of the following statements declares Salaried as a subclass of payType? Public class Salaried implements PayType Public class Salaried derivedFrom(payType) Public class PayType derives Salaried Public class Salaried extends PayType If a method in a subclass has the same signature as a method in the superclass, the subclass method overrides the superclass method. False True When a subclass overloads a superclass method………. Only the subclass method may be called with a subclass object Only the superclass method...

  •            1.         You often need to know the inheritance ____________________ of the Java API to work...

               1.         You often need to know the inheritance ____________________ of the Java API to work with its classes and subclasses.            2.         All objects have access to the methods of the ____________ class.            3.         If two classes share some common elements, you can define those elements in a ____________.            4.         To call a constructor or method of a superclass from a subclass, you use the ____________ keyword.            5.         A class that can be inherited by another...

  • Java Lab In this lab, you will be implementing the following class hierarchy. Your concrete classes...

    Java Lab In this lab, you will be implementing the following class hierarchy. Your concrete classes must call the superclass constructor with the proper number of sides (which is constant for each concrete shape). The perimeter method is implemented in the superclass as it does not change based on the number of sides. The area method must be overridden in each subclass as the area is dependent on the type of polygon. The areas of an equilateral triangle, square, and...

  • Java Program Please help me with this. It should be pretty basic and easy but I...

    Java Program Please help me with this. It should be pretty basic and easy but I am struggling with it. Thank you Create a superclass called VacationInstance Variables destination - String budget - double Constructors - default and parameterized to set all instance variables Access and mutator methods budgetBalance method - returns the amount the vacation is under or over budget. Under budget is a positive number and over budget is a negative number. This method will be overwritten in...

  • Please help me with the following question. This is for Java programming. In this assignment you...

    Please help me with the following question. This is for Java programming. In this assignment you are going to demonstrate the uses of inheritance and polymorphism. You will create an Animals class and a Zoo class that holds all the animals. You should create a general Animalclass where all other classes are derived from (except for the Zoo class). You should then create general classes such as Mammal, Reptile, and whatever else you choose based off of the Animalclass. For...

  • Please help me with the following question. This is for Java programming. In this assignment you are going to demonstrate the uses of inheritance and polymorphism. You will create an Animals class and...

    Please help me with the following question. This is for Java programming. In this assignment you are going to demonstrate the uses of inheritance and polymorphism. You will create an Animals class and a Zoo class that holds all the animals. You should create a general Animalclass where all other classes are derived from (except for the Zoo class). You should then create general classes such as Mammal, Reptile, and whatever else you choose based off of the Animalclass. For...

  • In this lab you will work with abstract classes/interfaces. (Java Program) You will be implementing a...

    In this lab you will work with abstract classes/interfaces. (Java Program) You will be implementing a basic employee schema within a company. The Employee class will be an abstract class that will contain methods applicable to all employees. You will then create 2 classes called SoftwareEngineer and ProductManager. Both are different employee types based on occupation. You will create an interface called Developer which will consist of specific methods that apply to only Developers (e.g. SoftwareEngineer class will implement this,...

  • Use Java and please try and show how to do each section. You are creating a 'virtual pet' program...

    Use Java and please try and show how to do each section. You are creating a 'virtual pet' program. The pet object will have a number of attributes, representing the state of the pet. You will need to create some entity to represent attributes in general, and you will also need to create some specific attributes. You will then create a generic pet class (or interface) which has these specific attributes. Finally you will make at least one subclass of...

  • JAVA please: This lab has four parts: 1. Write a Person class. 2. Write a Student...

    JAVA please: This lab has four parts: 1. Write a Person class. 2. Write a Student and Employee subclass to Person. 3. Write a Faculty and Staff subclass to Employee. 4. Write a program that creates an object of all of the above classes. Task 1 – The Person Class First, let us make a simple class titled Person. A person should include: 1. The class variables/attributes/properties: a. Name, b. Address, c. Phone number, d. And email address. 2. An...

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