Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In Object-Oriented programming, an Object communicates to other Objects to use functionality and services provided by that object.Have you wondered how an object of a

In Object-Oriented programming, an Object communicates to other Objects 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 others. For example, a passport belongs to only one citizen.

Now refer the Schema for User class, it has attribute Contact details in it. Instead of using all the attributes in a single class, we distinguish separate domains into different classes(Like address, Contact detail).

A Contact detail belongs to a single user. So they form aoneto one(uni-directional)relationship. Let's try it out.

Create a class namedUserhaving private attributes

AttributesDatatypenameStringusernameStringpasswordStringcontactDetailContactDetail

Create a class namedContacthaving private attributes

AttributesDatatypemobileStringalternateMobileStringlandLineStringaddressString

Use __init__() method for initializing the attributes of the above classes.

Override __str__() method in both the classes to match the output format requirement

Hint:The input CSV format for User details isname,username,password

The input CSV format for Contact details ismobile,alternateMobile,landLine,address

[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.]

[All text in bold corresponds to the input and rest corresponds to output]

Sample Input and Output:

Enter user detail's

Ganesh Ram,Ram,ram@123

Enter contact d..g@abc.in,22nd street kk n..m@1..g@abc.inn Object-Oriented programming, an Object communicates to other Objects 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 others. For example, a passport belongs to only one citizen.

Now refer the Schema for User class, it has attribute Contact details in it. Instead of using all the attributes in a single class, we distinguish separate domains into different classes(Like address, Contact detail).

A Contact detail belongs to a single user. So they form aoneto one(uni-directional)relationship. Let's try it out.

Create a class namedUserhaving private attributes

AttributesDatatypenameStringusernameStringpasswordStringcontactDetailContactDetail

Create a class namedContacthaving private attributes

AttributesDatatypemobileStringalternateMobileStringlandLineStringaddressString

Use __init__() method for initializing the attributes of the above classes.

Override __str__() method in both the classes to match the output format requirement

Hint:The input CSV format for User details isname,username,password

The input CSV format for Contact details ismobile,alternateMobile,landLine,address

[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.]

[All text in bold corresponds to the input and rest corresponds to output]

Sample Input and Output:

Enter user detail's

Ganesh Ram,Ram,ram@123

Enter contact d..g@abc.in,22nd street kk n..m@1..g@abc.in

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

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

More Books

Students also viewed these Programming questions

Question

How do i create a new flashcard deck with Chegg study?

Answered: 1 week ago