Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Class notes

CLASSES AND OBJECTS 2

Rating
-
Sold
-
Pages
2
Uploaded on
24-12-2023
Written in
2023/2024

The word Algorithm means “A set of rules to be followed in calculations or other problem-solving operations” Or “A procedure for solving a mathematical problem in a finite number of steps that frequently involves recursive operations “.

Show more Read less
Institution
Course

Content preview

Introduction to Classes and Objects - Part 2 (Data
Structures & Algorithms #4)
CS Dojo
Introduction to Classes and Objects - Part 2
In the previous video, we created a class called "Robot" with attributes such as
name, colour, and weight. We also created two objects of this class, "Tom" and
"Jerry".
Now, let's introduce another class called "Person" with attributes like name,
personality, and sitting. We can create objects of this class as well, such as
"Alice" and "Becky".
To show the relationship between a person and a robot, we can add an attribute
called "robot Owned" to the "Person" class, which will store the robot object
owned by the person.
We can also define methods like "sit-down" and "standup" in the "Person" class
to change the value of the "is Sitting" attribute.
To implement the interaction between the classes, we can set the "robot Owned"
attribute of a person object to a robot object.
Similarly, if we want to show the relationship between robots, we can add an
attribute called "looking at" to the "Robot" class. We can then set the value of
this attribute to another robot object to indicate that one robot is looking at
another robot.
In summary, by adding attributes and setting their values, we can express
relationships between multiple classes and objects.
Implementing the Code
In Java, we can create a class called "Robot" with attributes and a constructor to
create objects. We can also define a method to introduce the object.
Next, we can create a class called "Person" with attributes and a constructor. We
can also define methods to sit down and stand up.
To show the relationship between a person and a robot, we can set the "robot
Owned" attribute of a person object to a robot object.

Written for

Course

Document information

Uploaded on
December 24, 2023
Number of pages
2
Written in
2023/2024
Type
Class notes
Professor(s)
Cs dojo
Contains
All classes

Subjects

$12.49
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
priyankas

Get to know the seller

Seller avatar
priyankas SRI RAMAKRISHNA COLLEGE OF ATS AND SCIENCE
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
2 year
Number of followers
0
Documents
6
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions