title
Introduction to Classes and Objects - Part 2 (Data Structures & Algorithms #4)

description
Object oriented programming tutorial #2! Java & Python sample code available below. Check out Brilliant.org (https://brilliant.org/CSDojo/), a website for learning math and computer science concepts through solving problems. First 200 subscribers will get 20% off through the link above. Special thanks to Brilliant for sponsoring this video. Find sample code in Python and Java here: https://www.csdojo.io/class2 You can find the entire data structures & algorithms series in a playlist here: https://goo.gl/wy3CWF Also, keep in touch on Facebook: https://www.facebook.com/entercsdojo

detail
{'title': 'Introduction to Classes and Objects - Part 2 (Data Structures & Algorithms #4)', 'heatmap': [{'end': 403.892, 'start': 386.4, 'weight': 0.74}, {'end': 442.845, 'start': 420.514, 'weight': 0.702}, {'end': 671.329, 'start': 646.292, 'weight': 1}], 'summary': 'Introduces classes and objects, covering object interaction, creation of person and robot classes with attributes and methods, and demonstrating java object relationships with examples. it also mentions future topics and is sponsored by brilliant.org.', 'chapters': [{'end': 197.308, 'segs': [{'end': 76.343, 'src': 'embed', 'start': 0.449, 'weight': 0, 'content': [{'end': 5.012, 'text': 'Hey guys, this is part two of my introduction to classes and objects.', 'start': 0.449, 'duration': 4.563}, {'end': 11.016, 'text': "And in this video, I'm going to talk about how multiple classes and objects can interact with each other.", 'start': 5.773, 'duration': 5.243}, {'end': 12.297, 'text': "So let's get started.", 'start': 11.477, 'duration': 0.82}, {'end': 15.239, 'text': 'Now, just a quick recap of the last video.', 'start': 12.998, 'duration': 2.241}, {'end': 21.083, 'text': 'We created this class called Robot with the three attributes, name, color, and weight.', 'start': 15.72, 'duration': 5.363}, {'end': 26.027, 'text': 'Name was a string, color was a string as well, and weight was an integer.', 'start': 21.624, 'duration': 4.403}, {'end': 29.79, 'text': 'and it had only one function called introduceSelf.', 'start': 27.087, 'duration': 2.703}, {'end': 36.077, 'text': "And when this function is run, it'll just print out, my name is name, whatever the name is.", 'start': 30.531, 'duration': 5.546}, {'end': 39.82, 'text': 'And then out of this class, we created two objects.', 'start': 36.937, 'duration': 2.883}, {'end': 48.707, 'text': "The first one was this one, A robot object with the name Tom, color red, and weight 30 to show that it's 30 pounds.", 'start': 40.541, 'duration': 8.166}, {'end': 56.432, 'text': 'And the second object was a robot object with the name Jerry, color blue, and weight 40.', 'start': 49.428, 'duration': 7.004}, {'end': 63.497, 'text': 'And we put the first object in this variable called r1, and then we put the second object in this variable called r2.', 'start': 56.432, 'duration': 7.065}, {'end': 68.04, 'text': "Now let's say on top of that, we have another class here.", 'start': 64.736, 'duration': 3.304}, {'end': 73.662, 'text': 'This class is going to be called person to represent any person you want to represent.', 'start': 68.8, 'duration': 4.862}, {'end': 76.343, 'text': "And it's going to have three attributes.", 'start': 74.302, 'duration': 2.041}], 'summary': 'Introduction to classes and objects, with examples of multiple objects interacting and their attributes.', 'duration': 75.894, 'max_score': 0.449, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/4dqlSk_RPmI/pics/4dqlSk_RPmI449.jpg'}, {'end': 149.913, 'src': 'embed', 'start': 98.331, 'weight': 2, 'content': [{'end': 102.093, 'text': "Using this class, we'll be able to create a couple of objects here as well.", 'start': 98.331, 'duration': 3.762}, {'end': 105.355, 'text': 'And the first object here might look like this.', 'start': 102.594, 'duration': 2.761}, {'end': 113.58, 'text': 'This is going to be a person object, of course, with the name Alice, personality, aggressive, and is sitting, false.', 'start': 105.896, 'duration': 7.684}, {'end': 116.662, 'text': "So this person is not sitting, she's probably standing.", 'start': 114.081, 'duration': 2.581}, {'end': 120.344, 'text': 'And the second object here might look like this.', 'start': 117.663, 'duration': 2.681}, {'end': 128.407, 'text': 'This is a person object with the name Becky, personality, talkative, and is sitting true.', 'start': 121.425, 'duration': 6.982}, {'end': 135.608, 'text': "And let's put the first object here, the person named Alice, to this variable called p1.", 'start': 128.987, 'duration': 6.621}, {'end': 142.97, 'text': "And then let's put the second object here to p2 to show that this is person 1 and this is person 2.", 'start': 136.088, 'duration': 6.882}, {'end': 147.972, 'text': "And let's say this person class has a few methods or a few functions as well.", 'start': 142.97, 'duration': 5.002}, {'end': 149.913, 'text': 'Sit down and stand up.', 'start': 148.612, 'duration': 1.301}], 'summary': 'Creating person objects with attributes and methods, p1 not sitting, p2 sitting', 'duration': 51.582, 'max_score': 98.331, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/4dqlSk_RPmI/pics/4dqlSk_RPmI98331.jpg'}], 'start': 0.449, 'title': 'Object interaction and person class creation', 'summary': 'Covers the interaction between classes and objects, including the creation of classes, objects, and their attributes with a focus on robot and person classes. it also explains the creation of a person class with attributes such as name, personality, and is sitting, and the use of methods like sit down and stand up to modify the is sitting value, demonstrated through the creation of person objects, alice and becky.', 'chapters': [{'end': 76.343, 'start': 0.449, 'title': 'Classes and objects interaction', 'summary': 'Explains how multiple classes and objects interact with each other, covering the creation of classes, objects, and their attributes. it also discusses the functions and variables used, with a focus on robot and person classes.', 'duration': 75.894, 'highlights': ['The video introduces the concept of multiple classes and objects interacting with each other, focusing on the classes Robot and Person, and their respective attributes and functions.', 'It discusses the creation of a class named Robot with attributes such as name, color, and weight, and a function called introduceSelf.', 'The class Robot is used to create two objects, one with the name Tom, color red, and weight 30, and the other with the name Jerry, color blue, and weight 40.']}, {'end': 197.308, 'start': 77.263, 'title': 'Creating person objects and their functions', 'summary': 'Explains the creation of a person class with attributes such as name, personality, and is sitting, and the use of methods like sit down and stand up to modify the is sitting value, demonstrated through the creation of person objects, alice and becky.', 'duration': 120.045, 'highlights': ['The chapter explains the creation of a Person class with attributes such as name, personality, and is sitting.', 'The use of methods like sit down and stand up to modify the is sitting value, demonstrated through the creation of person objects, Alice and Becky.', 'Demonstrating the functionality of methods sit down and stand up with the person objects.']}], 'duration': 196.859, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/4dqlSk_RPmI/pics/4dqlSk_RPmI449.jpg', 'highlights': ['The video introduces the concept of multiple classes and objects interacting with each other, focusing on the classes Robot and Person, and their respective attributes and functions.', 'The class Robot is used to create two objects, one with the name Tom, color red, and weight 30, and the other with the name Jerry, color blue, and weight 40.', 'The chapter explains the creation of a Person class with attributes such as name, personality, and is sitting.', 'The use of methods like sit down and stand up to modify the is sitting value, demonstrated through the creation of person objects, Alice and Becky.', 'It discusses the creation of a class named Robot with attributes such as name, color, and weight, and a function called introduceSelf.', 'Demonstrating the functionality of methods sit down and stand up with the person objects.']}, {'end': 449.749, 'segs': [{'end': 329.117, 'src': 'embed', 'start': 213.818, 'weight': 0, 'content': [{'end': 224.921, 'text': 'So for example, this person named Becky might own this robot named Tom, and this person, Alice, might own this other robot, Jerry.', 'start': 213.818, 'duration': 11.103}, {'end': 232.103, 'text': 'So how can we express that? One way to show that is having an extra attribute to the Person class.', 'start': 225.521, 'duration': 6.582}, {'end': 236.625, 'text': 'And that attribute might be called something like robot owned.', 'start': 232.943, 'duration': 3.682}, {'end': 242.329, 'text': "This is going to be the particular robot that's owned by this person.", 'start': 237.426, 'duration': 4.903}, {'end': 244.97, 'text': 'And this is going to be a robot object.', 'start': 242.929, 'duration': 2.041}, {'end': 254.396, 'text': 'So, for example, if you want to show that Alice owns Jerry, which is in this variable called R2,', 'start': 245.651, 'duration': 8.745}, {'end': 259.839, 'text': 'you can just set the robot owned attribute of this person object to R2..', 'start': 254.396, 'duration': 5.443}, {'end': 267.564, 'text': 'and this is going to show that p1 owns r2, and then you can do the same thing for p2.', 'start': 261.38, 'duration': 6.184}, {'end': 275.449, 'text': 'becky, if you want to show that this person owns this robot, which is in the r1 variable,', 'start': 267.564, 'duration': 7.885}, {'end': 281.653, 'text': 'you can just set the robot on attribute of this person to r1,', 'start': 275.449, 'duration': 6.204}, {'end': 287.537, 'text': 'and this is one very common way of expressing the relationships between multiple classes and objects.', 'start': 281.653, 'duration': 5.884}, {'end': 292.014, 'text': "Okay, let's now see how we can actually implement that using code.", 'start': 288.47, 'duration': 3.544}, {'end': 299.181, 'text': "I'm going to use Java as an example here, but other languages like Python are going to be usually pretty similar.", 'start': 292.755, 'duration': 6.426}, {'end': 302.885, 'text': "And let's just quickly recap what we did in the last video.", 'start': 299.982, 'duration': 2.903}, {'end': 309.012, 'text': 'We defined a class called robot by writing class robot curly brackets.', 'start': 303.586, 'duration': 5.426}, {'end': 316.261, 'text': 'and this class had three attributes or three instance variables string name,', 'start': 310.433, 'duration': 5.828}, {'end': 324.13, 'text': 'string color and integer weight and we also defined a constructor for creating a new object out of this class,', 'start': 316.261, 'duration': 7.869}, {'end': 329.117, 'text': 'and that one took three arguments string n, string c, int,', 'start': 324.13, 'duration': 4.987}], 'summary': "Using extra attribute 'robot owned' to express ownership in classes and objects in java and python.", 'duration': 115.299, 'max_score': 213.818, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/4dqlSk_RPmI/pics/4dqlSk_RPmI213818.jpg'}, {'end': 386.4, 'src': 'embed', 'start': 360.84, 'weight': 5, 'content': [{'end': 367.025, 'text': 'The first object had the name Tom, color red, and weight 30, and so on.', 'start': 360.84, 'duration': 6.185}, {'end': 375.912, 'text': 'And then we were able to, of course, use this function introduceSelf by writing r1.introduceSelf and r2.introduceSelf.', 'start': 367.866, 'duration': 8.046}, {'end': 386.4, 'text': "and just a quick note if you want to implement this yourself, you'll be able to put both of these blocks of code in a single file and then for me,", 'start': 376.793, 'duration': 9.607}], 'summary': 'The transcript discusses objects named tom and function introduceself.', 'duration': 25.56, 'max_score': 360.84, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/4dqlSk_RPmI/pics/4dqlSk_RPmI360840.jpg'}, {'end': 414.672, 'src': 'heatmap', 'start': 386.4, 'weight': 0.74, 'content': [{'end': 393.865, 'text': "i'm going to call it test robot and person java, and you'll be able to find a link to this file in the description below as well.", 'start': 386.4, 'duration': 7.465}, {'end': 403.892, 'text': "okay, moving forward, to implement what i explained earlier, each person owning a particular robot, let's create a person class by writing, of course,", 'start': 393.865, 'duration': 10.027}, {'end': 414.672, 'text': 'class, person, curly brackets, And then this person class will have these attributes string name, string personality, and Boolean is sitting.', 'start': 403.892, 'duration': 10.78}], 'summary': 'Creating a person class with attributes: name, personality, issitting', 'duration': 28.272, 'max_score': 386.4, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/4dqlSk_RPmI/pics/4dqlSk_RPmI386400.jpg'}, {'end': 449.749, 'src': 'heatmap', 'start': 420.514, 'weight': 2, 'content': [{'end': 428.396, 'text': "And then to show that each person owns a particular robot, we'll need to add another attribute, of course, called robot owned.", 'start': 420.514, 'duration': 7.882}, {'end': 433.479, 'text': 'And this robot-owned, the value of this attribute will be a robot object.', 'start': 429.056, 'duration': 4.423}, {'end': 437.542, 'text': 'So the type of this attribute will need to be robot.', 'start': 433.959, 'duration': 3.583}, {'end': 442.845, 'text': 'And then just like we did with the robot class, we can create a constructor here as well.', 'start': 438.262, 'duration': 4.583}, {'end': 449.749, 'text': 'This constructor is going to be called person because we need to call a constructor the same name as the class.', 'start': 443.605, 'duration': 6.144}], 'summary': "Adding a 'robot owned' attribute to the person class with a value of a robot object.", 'duration': 45.857, 'max_score': 420.514, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/4dqlSk_RPmI/pics/4dqlSk_RPmI420514.jpg'}], 'start': 197.308, 'title': 'Java object relationships and class creation', 'summary': "Covers expressing object relationships in java, demonstrating ownership between people and robots with examples, creating a 'robot' class with attributes and a method, and implementing person and robot classes with specific attributes and constructors.", 'chapters': [{'end': 299.181, 'start': 197.308, 'title': 'Object relationship in java', 'summary': 'Discusses expressing relationships between classes and objects, specifically demonstrating how to show ownership between people and robots using an extra attribute in java, with examples of becky owning tom and alice owning jerry.', 'duration': 101.873, 'highlights': ['Demonstrating ownership between people and robots using an extra attribute in Java, with examples of Becky owning Tom and Alice owning Jerry.', "Illustrating the process of setting the 'robot owned' attribute of a person object to show ownership, such as setting the attribute to R2 for Alice owning Jerry and to R1 for Becky owning Tom.", 'Explaining the common method of expressing relationships between multiple classes and objects through setting attributes to show ownership.']}, {'end': 386.4, 'start': 299.982, 'title': 'Creating robot class', 'summary': "Covers the creation of a class 'robot' with three attributes (name, color, weight), a constructor with three arguments, and a method 'introduceself'; demonstrated through the creation and utilization of objects, including one named 'tom' with color red and weight 30.", 'duration': 86.418, 'highlights': ["The chapter covers the creation of a class 'robot' with three attributes (name, color, weight), a constructor with three arguments, and a method 'introduceSelf'", "Demonstrated the creation and utilization of objects, including one named 'Tom' with color red and weight 30", 'Defined a class called robot, with three attributes: string name, string color, and integer weight']}, {'end': 449.749, 'start': 386.4, 'title': 'Implementing person and robot classes in java', 'summary': 'Discusses implementing a person class with attributes such as name, personality, and ownership of a robot, as well as the creation of a constructor for the person class.', 'duration': 63.349, 'highlights': ['Creating a person class with attributes such as name, personality, and ownership of a robot, as well as the implementation of a constructor for the person class.', 'The person class will have attributes string name, string personality, and Boolean is sitting, and an additional attribute called robot owned, with the value of this attribute being a robot object.']}], 'duration': 252.441, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/4dqlSk_RPmI/pics/4dqlSk_RPmI197308.jpg', 'highlights': ['Demonstrating ownership between people and robots using an extra attribute in Java, with examples of Becky owning Tom and Alice owning Jerry.', "The chapter covers the creation of a class 'robot' with three attributes (name, color, weight), a constructor with three arguments, and a method 'introduceSelf'", 'Creating a person class with attributes such as name, personality, and ownership of a robot, as well as the implementation of a constructor for the person class.', "Illustrating the process of setting the 'robot owned' attribute of a person object to show ownership, such as setting the attribute to R2 for Alice owning Jerry and to R1 for Becky owning Tom.", 'Explaining the common method of expressing relationships between multiple classes and objects through setting attributes to show ownership.', "Demonstrated the creation and utilization of objects, including one named 'Tom' with color red and weight 30", 'Defined a class called robot, with three attributes: string name, string color, and integer weight', 'The person class will have attributes string name, string personality, and Boolean is sitting, and an additional attribute called robot owned, with the value of this attribute being a robot object.']}, {'end': 903.212, 'segs': [{'end': 671.329, 'src': 'heatmap', 'start': 646.292, 'weight': 0, 'content': [{'end': 653.194, 'text': "And of course, this line, once executed, will print out, my name is Tom, because that's the name of r1.", 'start': 646.292, 'duration': 6.902}, {'end': 659.399, 'text': "So that's how you can express the relationships between robots and person objects.", 'start': 654.014, 'duration': 5.385}, {'end': 662.541, 'text': 'But can we do something similar within the same class?', 'start': 660.039, 'duration': 2.502}, {'end': 671.329, 'text': 'So, for example, what if you had these five robots and each of them can be expressed as a robot object?', 'start': 663.242, 'duration': 8.087}], 'summary': 'Demonstrates how to express relationships between robots and person objects within the same class.', 'duration': 25.037, 'max_score': 646.292, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/4dqlSk_RPmI/pics/4dqlSk_RPmI646292.jpg'}, {'end': 847.968, 'src': 'embed', 'start': 817.303, 'weight': 2, 'content': [{'end': 822.327, 'text': "If there's any related topic that you want me to cover in the future though, just let me know in the comment below.", 'start': 817.303, 'duration': 5.024}, {'end': 826.249, 'text': 'And special thanks to Brilliant.org for sponsoring this video.', 'start': 822.987, 'duration': 3.262}, {'end': 831.673, 'text': "So in my next video in this series, I'm planning to cover the topic of linked lists.", 'start': 826.95, 'duration': 4.723}, {'end': 836.736, 'text': 'But actually, once you understood the concepts you learned in this video,', 'start': 832.213, 'duration': 4.523}, {'end': 841.84, 'text': "you'll be able to start learning more advanced data structures like graphs and trees.", 'start': 836.736, 'duration': 5.104}, {'end': 847.968, 'text': 'So if you want to jump ahead and start learning these concepts on your own, you might want to check out Brilliant.', 'start': 842.7, 'duration': 5.268}], 'summary': 'Future video will cover linked lists; prepares for advanced structures like graphs and trees. sponsored by brilliant.org.', 'duration': 30.665, 'max_score': 817.303, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/4dqlSk_RPmI/pics/4dqlSk_RPmI817303.jpg'}], 'start': 450.37, 'title': 'Introduction to classes and objects', 'summary': 'Introduces classes and objects, covering the creation of person and robot objects, defining their attributes, methods, and relationships. it also mentions future topics and is sponsored by brilliant.org.', 'chapters': [{'end': 903.212, 'start': 450.37, 'title': 'Introduction to classes and objects', 'summary': 'Introduces classes and objects, covering the creation of person and robot objects, defining their attributes, methods, and relationships, and also mentions future topics, sponsored by brilliant.org.', 'duration': 452.842, 'highlights': ['Creation of person and robot objects', 'Defining relationships between person and robot objects', 'Future topics and sponsorship']}], 'duration': 452.842, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/4dqlSk_RPmI/pics/4dqlSk_RPmI450370.jpg', 'highlights': ['Creation of person and robot objects', 'Defining relationships between person and robot objects', 'Future topics and sponsorship']}], 'highlights': ['The video introduces the concept of multiple classes and objects interacting with each other, focusing on the classes Robot and Person, and their respective attributes and functions.', 'Demonstrating ownership between people and robots using an extra attribute in Java, with examples of Becky owning Tom and Alice owning Jerry.', 'The chapter explains the creation of a Person class with attributes such as name, personality, and is sitting.', 'Creating a person class with attributes such as name, personality, and ownership of a robot, as well as the implementation of a constructor for the person class.', 'Defined a class called robot, with three attributes: string name, string color, and integer weight', 'Defined the person class with attributes string name, string personality, and Boolean is sitting, and an additional attribute called robot owned, with the value of this attribute being a robot object.', 'Demonstrating the functionality of methods sit down and stand up with the person objects.', "Illustrating the process of setting the 'robot owned' attribute of a person object to show ownership, such as setting the attribute to R2 for Alice owning Jerry and to R1 for Becky owning Tom.", 'The class Robot is used to create two objects, one with the name Tom, color red, and weight 30, and the other with the name Jerry, color blue, and weight 40.', "Demonstrated the creation and utilization of objects, including one named 'Tom' with color red and weight 30", 'The use of methods like sit down and stand up to modify the is sitting value, demonstrated through the creation of person objects, Alice and Becky.', 'Explaining the common method of expressing relationships between multiple classes and objects through setting attributes to show ownership.', "The chapter covers the creation of a class 'robot' with three attributes (name, color, weight), a constructor with three arguments, and a method 'introduceSelf'", 'The creation of a class named Robot with attributes such as name, color, and weight, and a function called introduceSelf.', 'Creation of person and robot objects', 'Defining relationships between person and robot objects', 'Future topics and sponsorship']}