Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please provide the java code for the above question. Please dont post the code as images. 4 One to One relationship (Uni-directional) In Object-Oriented programming,

image text in transcribedimage text in transcribedimage text in transcribed

Please provide the java code for the above question. Please dont post the code as images.

4 One to One relationship (Uni-directional) In Object-Oriented programming, an Object communicates to other object to use functionality and services provided by that object. Have you wondered how an object of a class is an attribute of another one?. That is called as a Relationship between two. Why am I going to use that? that's what we are going to see now. In real time certain domain has one to one relationship with other. For example, a passport belongs to only one citizen. Now refer the Schema for Student class, it has an attribute address in it. Instead of using all the attributes in a single class, we distinguish separate domains into different classes(Like Address, Student). A address belongs to a single student. So they form a one to one(uni-directional) relationship. Let's try it out. Create a class named Student having private attributes Attributes Datatype id Integer name String dept String mobile String address Address Then create the other class of the relationship, Address class with following attributes, Attributes Datatype addressLine1 String city String state String pincode Integer Include getter and setters for all attributes in both the classes Include default and parameterized constructors for both the classes in the following order Create a method display() in the user class to display all the details. Create a driver class called Main. In the Main method, obtain input from the user and display all the details. [Strictly adhere to the Object-Oriented Specifications given in the problem statement. All class names, attribute names and method names should be the same as specified in the problem statement.] Input Format The first set of input is the student details. The second set of input is the address details. Output Format The output prints the details. Refer sample input and output. Sample Testcases Testcase 1 Input Testcase 1 Output 1 Alice CSE 9876548569 Gandhi nagar Coimbatore Tamilnadu 641006 Alice CSE 9876548569 Gandhi nagar Coimbatore Tamilnadu 641006

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

Professional IPhone And IPad Database Application Programming

Authors: Patrick Alessi

1st Edition

0470636173, 978-0470636176

More Books

Students also viewed these Databases questions