Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

by java Example of Inheritance: Circle-Cylinder, the Circle is the super class of Cylinder. The Cylinder class is the sub-class of Circle. class Cylinder extends

by java

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

Example of Inheritance: Circle-Cylinder, the Circle is the super class of Cylinder. The Cylinder class is the sub-class of Circle. class Cylinder extends Circle { double height; public class Circle { int xcenter; int ycenter; double radius; Circle( ) { this(1.0); } Cylinder() { super(); height=1.0; } int y, double r, Circle(int x, int y, double r) { xcenter = x; ycenter = y; radius = r; } Cylinder(int X double h) { super(x, y, r); height=h; } Circle( double r){ this(0, 0, r); } Cylinder(int h){ height = h; } double findArea() { return 3.14*radius*radius; } double findVolume() { return super.findArea() *height; } } double findDiameter() { return 2*radius; } } http://hilite.me converts your code snippets into pretty-printed HTML format, easily embeddable into blog posts, emails, and websites. 3.6 Unified Modeling Language (UML) UML is a standard way to represent the class's skeleton. It is represented with a table of 3 rows: the first row: title, the second row: properties, and the third row: constructors and methods. As shown below, Eclipse IDE has an outline panel to represent UML. Person Description name: Name dateOfBirth: Date - numPerson-0: int Name of Person Date of Birth of Person Number of Person A Properties Outline x Person name: Name A dateOfBirth: Date Anum Person: int Person(String, String, int, int, int) A printinfo() : void A printAgeAtYear(int) : void A $ printNumberOfPerson : void +Person(firstName: String. lastName:String, day:int, int month:int, year: int) A constructor with 5 arguments. The constructor assigns input arguments into their corresponding properties eclipse Constructor + printinfo():void Method Print information of a person in the following format: Name: firstName lastName DOB: day-month-year Age: age printAge AtYear(int year):void Print the age of a person at input year in the format of Age: age + printNumberOfPerson():void Print the number of Persons in the following format The total number of Persons is numPerson Exercise 1: (2 points) Project Name : _LAB03_ CompanyHierarchy Instruction : Complete a class Person provided in a template using the given UML. Remark: Students should re-uses Java classes: Name.java, Date.java from Google Classroom. Person Description name: Name dateOfBirth: Date numPerson=0: int Name of Person Date of Birth of Person Number of Person Person(firstName: String, lastName: String, day:int, month:int, year:int) A constructor with 5 arguments. The constructor assigns input arguments into their corresponding properties printInfo():void Print information of a Person in the following format: Name: firstName lastName DOB: day-month-year Age: age printAgeAtYear(int year):void Print the age of a Person at input year in the format of Age: age print NumberOfPerson (:void Print the number of Persons in the following format The total number of Persons is num Person. mer Exercise 2: (2 points) Project Name Instruction : _LAB03_ Company Hierarchy : Complete a class Employee provided in a template using the given UML. Person Employee Description workplace: String position: String salary: double Workplace of Employee Position of Employee Salary of Employee A constructor with 8 arguments Employee(firstName: String, lastName: String, day:int, month:int, year:int, workplace:String, position: String, salary: double) printInfo():void Print info of Employee in the following format: Name: firstName lastName DOB: day-month-year Age: age Work Place: workplace Position: position Salary: salary followRule(rule:String ): void Print the input rule in the format of firstname lastname follows rule Position: firstname lastname Followed: rule 23 Exercise 3: (2 points) Project Name Instruction : _LAB03_CompanyHierarchy : Complete a class Executive provided in a template from the given UML. Employee Executive Description bonus: double bonus Bonus A constructor with 9 arguments Executive (firstName: String lastName:String, day:int, month: int, year:int, workplace:String, position: String, salary: double, bonus: double) printInfo():void Print info of an Executive in the following format Name: firstName lastName DOB: day-month-year Age: age Workplace: workplace Position: position Salary: salary Bonus: bonus announceRule(rule:String): void Print the input rule in the format of Position: firstname lastname Announces rule: rule 29 Exercise 4: (2 points) Project Name : _LAB03_Company Hierarchy Instruction : Complete a class CEO provided in a template from the given UML. Executive CEO Description positionVehicle: String position Vehicle A constructor with 10 arguments CEO(firstName:String, lastName:String, day:int, month:int, year:int, workplace: String, position: String, salary: double, bonus: double, positionVehicle:String) printInfo() : void Print information of an Executive in the following format: Name: firstName lastName DOB: day-month-year Age: XX Work Place: XXX Position: XXX Salary: XXX Bonus: XXX PositionVehicle: XXX showVision(String vision): void Print the input vision in the following format: firstname lastname shows vision Exercise 5: (2 points) Project Name : _LAB03_CompanyHierarchy Instruction : Complete a class TestCompanyHierarchy with a main method. In main, write the code that complete the following task. Hint: Student can download the skeleton class TestCompanyHierarchy in Google Classroom a) Print out title of "Company Information". Your running output should be as below: ### FUTURETECH COMPANY INFORMATION ### b) Print out a title of "Visitor Information" and call printInfo() of person01 and person02. Your running output should be as below: >> Visitor Information Name : Somyai Yodyium DOB: 15-4-1987 Age: 30 Name: Pitak Raksa DOB: 1-8-1980 Age: 37 c) Print out a title of "Employee Information" and call printInfo() of employee01 and employee02. Your running output should be as below: >> Employee Information Name: Maneeya Rinrom DOB: 15-4-1987 Age: 30 Work Place: FutureTech Co. Position: Secretary Salary: 15000.0 Name : Parinya Yenjid DOB: 5-11-1990 Age: 27 Work Place: FutureTech Co. Position: Technician Salary: 22000.0 d) Print out a title of "employee information" and call print Info() of executive01 and executive02. Your running output should be as below: >> Executive Information Name : Preecha Yanusit DOB: 30-4-1977 Age: 40 Work Place: Future Tech Co. Position: Sale Manager Salary: 40000.0 Bonus: 80000.0 Name : Songpol Sangar DOB: 10-11-1972 Age: 45 Work Place: Future Tech Co. Position: Finance Manager Salary: 38000.0 Bonus: 76000.0 e) Print out title of "Rule Announcement" and call the method announceRule() with input String "No nap during working hours" of executive01. Your running output should be as below: >> Rule Announcement Sale Manager: Preecha Yanusit Announces rule: No nap during working hours f) Print out title of "Rule Follower and call followRule() method with input String "No nap during working hours" of employee01 and employee02. Your running output should be as below: >> Rule Follower Secretary:Maneeya Rinrom Followed: No nap during work hours Technician: Parinya Yenjid Followed: No nap during work hours g) Print out title of "CEO Information" and call printInfo() of ceoo. Your running output should be as below: >> CEO Information Name : Sipol Tongyai DOB: 19-9-1956 Age: 61 Work Place: Future Tech Co. Position: President Salary: 150000.0 Bonus: 500000.0 position Vehicle: BMW A5 h) Print out title of "CEO Vision" and call showVision () of ceo01 with input String "becoming ISO standard". Your running output should be as below: >> CEO Vision Sipol Tongyai shows becoming ISO standard i) Print out title of "Number of Person" and call the static method print NumberOfPerson from the Person class. Your running output should be as below: >> Number of Person The total number of Persons is 7 persons. Student can copy the class skeleton TestCompanyHierarchy as follows: // TestCompanyHierarchy.java public class TestCompanyHierarchy { public static void main(String[] args) { // a) print out title of "company information". // >> student can write your code here // b) print out a title of "Visitor Information" and call printInfo() of person01 and person02 // >> student can write your code here //print out title // construct Person objects // >> student can write your code here // >> student can write your code here // print out information // >> student can write your code here System.out.println("- -"); // >> student can write your code here System.out.println("- -In"); // c) print out a title of "Employee Information and call printInfo() of employee01 and employee02. // >> student can write your code here //print out title // construct Employee objects // >> student can write your code here // >> student can write your code here // print out employee information // >> student can write your code here System.out.println(" "); // >> student can write your code here System.out.println("- - "); // d) print out a title of "Executive information" and call printInfo() of executive01 and executive02. // >> student can write your code here //print out title // construct Executive objects // >> student can write your code here // >> student can write your code here // print out employee information // >> student can write your code here System.out.println(" -"); // >> student can write your code here System.out.println("- - "); // e) print out title of "Rule Announcement" and // call the method announceRule() with input String "take no nap during working hours of executive01. // >> student can write your code here //print out title // >> student can write your code here System.out.println("- - "); // f) print out title of "Rule Follower" and // call followRule() method with input String "No nap during working hours of employee01 and employee02. // >> student can write your code here //print out title // >> student can write your code here DOB: 30-4-1977 Age: 40 Work Place: FutureTech Co. Position: Sale Manager Salary: 40000.0 Bonus: 80000.0 Name: Songpol Sangar DOB: 10-11-1972 Age: 45 Work Place: FutureTech co. Position: Finance Manager Salary: 38000.0 Bonus: 76000.0 >> Rule Announcement Sale Manager: Preecha Yanusit Announces rule: No nap during working hours >> Rule Follower Secretary: Maneeya Rinrom Followed: No nap during work hours Technician: Parinya Yenjid Followed: No nap during work hours >> CEO Information Name: Sipol Tongyai DOB: 19-9-1956 Age: 61 Work Place: FutureTech co. Position: President Salary: 150000.0 Bonus: 500000.0 position Vehicle: BMW A5 >> CEO Vision Sipol Tongyai shows becoming ISO standard >> Number of Person The total number of Persons is 7 persons

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

Expert Oracle9i Database Administration

Authors: Sam R. Alapati

1st Edition

1590590228, 978-1590590225

More Books

Students also viewed these Databases questions

Question

What is the basis for Security Concerns in Cloud Computing?

Answered: 1 week ago

Question

Describe the three main Cloud Computing Environments.

Answered: 1 week ago