Indications:
Person is an abstract class containing the abstract method Print().
In Teacher and Student the method print() will print the information of either Teacher or Student.
Write the class university corresponding to the following UML diagram. It contains three attributes.
Tab is an array of Person. sizeTab is the size of Tab. The attribute n represents the number of elements added to the tab. When the tab is empty n is equal to 0.
The constructor University(sizeTab) will initialize the different attributes and allocate the memory to the array Tab.
addPerson(p:Person) will add the new person to Tab.
The method printAll() will print all the information of the Persons inside Tab.
Write the main method. Create three Teacher and three Student and add them to University Object and print them all.
Step by stepSolved in 3 steps with 1 images
- The base class Pet has attributes name and age. The derived class Dog inherits attributes from the base class Pet class and includes a breed attribute. Complete the program to: Create a generic pet, and print the pet's information using print_info(). Create a Dog pet, use print_info() to print the dog's information, and add a statement to print the dog's breed attribute. Ex: If the input is: Dobby 2 Kreacher 3 German Schnauzer the output is: Pet Information: Name: Dobby Age: 2 Pet Information: Name: Kreacher Age: 3 Breed: German Schnauzer Here is the original code: class Pet:def __init__(self):self.name = ''self.age = 0 def print_info(self):print('Pet Information:')print(' Name:', self.name)print(' Age:', self.age) class Dog(Pet):def __init__(self):Pet.__init__(self)self.breed = '' my_pet = Pet()my_dog = Dog() pet_name = input()pet_age = int(input())dog_name = input()dog_age = int(input())dog_breed = input() # TODO: Create generic pet (using pet_name, pet_age) and then call…arrow_forwardTask 3: Write the Movie class. The UML diagram of the class is represented below: Movie - name : String -year : int - leadActor : String - director : String Page of 3 Requirements: 1. Implement the class strictly according to its UML one-to-one (do not include anything extra, and do not miss any data fields or methods). (10 points) 2. Implement a Movie Test class to test the class Movie you just created. (Extra 5 points) Create two Movie objects: one using the no-args constructor and one from the constructor with all fields. Print the contents of both objects. Please submit a screenshot. Hint: toString() method. ZOOM + *karrow_forwardGoal 1: Update the Fractions Class ADD an implementation that takes an integer as a parameter. The functionality remains the same: Instead of multiplying/dividing the current object with another Fraction, it multiplies/divides with an integer. For example; a fraction 2/3 when multiplied by 4 becomes 8/3. Similarly, a fraction 2/3 when divided by 4 becomes 1/6. Goal 2: Update the Recipe Class Add a private member variable of type int to denote the serving size and initialize it to 1. Update the overloaded extraction operator (<<) to include the serving size. New Member functions to the Recipe Class: 1. Add four member functions get the value of each of the member variable of the Recipe class: getRecipeName(), getIngredientNames(), getIngredientQuantities(), getServingSize() They return the value of the respective member variables. 2. Add and implement a member function that scales the current recipe to a new serving size. The signature of this function is: void scaleRecipe(int…arrow_forward
- Implement a nested class composition relationship between any two class types from the following list: Advisor Вook Classroom Department Friend Grade School Student Teacher Tutor Write all necessary code for both classes to demonstrate a nested composition relationship including the following: a. one encapsulated data member for each class b. inline default constructor using constructor delegation for each class c. inline one-parameter constructor for each class d. inline accessors for all data members e. inline mutators for all data membersarrow_forward3. Design a user-defined class called Course. Each course object will hold data about a course. The data includes courseID, courseName, credits and instructorName. Define the instance variables required of the appropriate type. Provide only get methods along with toString() and equals() methods. Design another user-defined class called Student. Each student object will hold data on name, GPA and courseList. Make sure to define courseList as an ArrayList holding references to Course objects Implement a constructor that will take values to initialize name, and gpa while courseList is initialized to an ArrayList() object. Provide the following get methods: getStudent ID ( ), getName(), getGPA (), get Gender(), and get CourseList() Note: the getCouresList() method will return a copy of the coureList arraylist with copies of course objects. Provide the following set methods: setName(), setGPA (), setGender() Another method: addCourse () that will take a Course object and add it to the…arrow_forwardCode: import java.util.*; //Bicycle interface interface Bicycle { abstract void changeCadence(int newValue); //will change value of candence to new value abstract void changeGear (int newValue); //changes gear of car abstract void speedUp(int increment); //increments speed of car by adding new Value to existing speed abstract void applyBrakes(int decrement); } //ACMEBicycle class definition class ACMEBicycle implements Bicycle { int cadence = 0; Â Â int speed = 0; Â Â int gear = 1; //methods of interface public void changeCadence(int newValue) { this.cadence=newValue; } public void changeGear (int newValue) { this.gear=newValue; } public void speedUp(int increment) { this.speed+=increment; } public void applyBrakes(int decrement) { this.speed-=decrement; } //display method void display() { System.out.println("Cadence: "+this.cadence); System.out.println("Gear: "+this.gear); System.out.println("Speed: "+this.speed); } } //KEYOBicycle class definition class KEYOBicycle implements…arrow_forward
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY