Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a class Student and another class Instructor. [ Details are unimportant at this stage, and yes, this will be very poor O - O

Create a class Student and another class Instructor. [Details are unimportant at this stage, and yes, this will be very poor O-O design!]. Let each class have a single instance variable name that contains a full name. Class Student is shown at right. [Remember to use Eclipse "source" shortcuts to create these classes very quickly!]
Suppose we want to require a behavior that displays a "role" as part of the name. For example:
Student
-name:String //full name
+Student(String n)
+getName(): String
toString():String
Stephen Weissman, instructor
Susan Holly, student
Create an interface RoleDisplayable to require a void method displayNameAndRole()
a. Code a default method for displayNameAndRole() that makes all Student instances display the name with ", Student" after the name.
b. Important: if it's not a Student, let's make the default method do nothing. [Maybe not great design, but it will make this lab more interesting!] How will you do this??
c. Also important: if you try to invoke getName() from your default method, you'll get a compile error! [Remember static and dynamic types? getName() is in the dynamic type Student!] To solve this problem, we'll need to add a cast before the dot and method call something like this: ((Student) this)
Make class Student implement RoleDisplayable.
Write a test driver (in main()) that
a. builds an ArrayList of
image text in transcribed

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_2

Step: 3

blur-text-image_3

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

Big Data Concepts, Theories, And Applications

Authors: Shui Yu, Song Guo

1st Edition

3319277634, 9783319277639

Students also viewed these Databases questions

Question

What are Measures in OLAP Cubes?

Answered: 1 week ago

Question

How do OLAP Databases provide for Drilling Down into data?

Answered: 1 week ago

Question

How are OLAP Cubes different from Production Relational Databases?

Answered: 1 week ago