ShmoopTube

Where Monty Python meets your 10th grade teacher.

Search Thousands of Shmoop Videos


Computer Science Videos 112 videos

Computer Science: Setting Up Your Environment
19 Views

Just as you move your furniture into a new house before spending the night, you’ve got to spend a little time setting up your environment when yo...

Computer Science: Doubles and Ints
17 Views

Doubles and ints. At first glance, it may look like this video will be about baseball and football statistics. But they're actually computer scienc...

AP Computer Science 1.1 Classes and Objects
468 Views

AP Computer Science: Classes and Objects Drill 1, Problem 1. Which of the following is a correct {/* Implementation */} for the isInsect method?

See All

AP Computer Science 1.1 Classes and Objects 468 Views


Share It!


Description:

AP Computer Science: Classes and Objects Drill 1, Problem 1. Which of the following is a correct {/* Implementation */} for the isInsect method?


Transcript

00:00

Sorry And here's your shmoop du jour brought to you

00:05

by arbitrary visual aids doesn't matter what they are A

00:08

cz long as they help you learn right Yeah well

00:11

given the following code stuff right here Which of the

00:25

following is a correct implementation Or the is insect method

00:31

With our meaning Whether it's insect Art and hear the

00:39

potential answers brought to you by the roman army Here

00:44

we go Okay well here we're being asked that correct

00:46

implementation of a method called is insect which is working

00:49

with an animal object and we're being given three different

00:52

potential ways to go about it It looks like the

00:55

ultimate goal is to grab the data from number of

00:58

legs represented here by delicious burger and determine whether or

01:02

not number of legs is greater than or equal to

01:05

six Right trick though is doing it properly Number of

01:10

legs lived right here in the animal class It's a

01:14

private imager So the rest of the program outside the

01:16

class won't be able to access the variable directly But

01:20

there's also a public access or method called get number

01:23

of legs that can fetch a number of legs for

01:26

us Well we'll need to use it to get it

01:28

Our sweet sweet data let's Take a look at implementation

01:31

one if number of legs is greater than or equal

01:34

to six return true else returned false well for starters

01:38

it trying to access number of leg isn't declared in

01:41

the scope of this function We need access number of

01:44

legs through the object A then even if that had

01:48

worked it's being a bit redundant with this return True

01:50

returned false business have given condition is true return True

01:54

Yeah no kidding but there's a better way Implementation to

01:58

is a little closer to what we want now It

02:00

specifies that number of legs his heart of objects but

02:03

it's still trying to directly access number of legs which

02:06

is a private variable so we need to use the

02:08

access or method implementation three is way better Not only

02:12

does it specify object a but it also calls the

02:14

animal class access or method get number of legs compares

02:18

the data to the number six and returns a true

02:20

or false statement All in one go implementation Three is

02:23

the only one that works with corresponds to cancer See 00:02:29.18 --> [endTime] that's our key to flavor country

Related Videos

AP Computer Science 2.3 Classes and Objects
191 Views

AP Computer Science 2.3 Classes and Objects. Which of the following is correct implementation of the Country class?

AP Computer Science 1.2 GridWorld Case Study and APIs
493 Views

AP Computer Science 1.2 GridWorld Case Study and APIs. What is the direction of the actor?

AP Computer Science 1.4 Standard Algorithms
200 Views

AP Computer Science 1.4 Standard Algorithms. How many times will mystery be called for mystery(n) for n > 1?

AP Computer Science 3.4 Inheritance, Abstraction, and Polymorphism
204 Views

AP Computer Science 3.4 Inheritance, Abstraction, and Polymorphism. Which of the following will satisfy the conditional if statement for boo, str,...

AP Computer Science 4.2 Standard Algorithms
191 Views

AP Computer Science 4.2 Standard Algorithms. What kind of algorithm is the following?