what's up guys the initial plan with
this video is just to make one big video
but it just ended up getting way too big
so I split them up into two and you'll
see me throughout these next two videos
talking as if it was one large video so
just don't get confused and enjoy the
video what's up guys my name is farce
night welcome two items are yet pisode
seven we are going to finish up Section
two now I know I said something about
section two before and said that I just
kind of would skim through it a little
bit but I went more in depth in section
two there are I believe three exercises
that we're gonna go over in this video
at least you're gonna see my solutions I
don't want to make a super long video
like last video is like twenty three
minutes and I don't know I want to keep
mine between ten and fifteen minutes so
I don't know we'll see we're gonna do at
least one completely you know maybe like
last time you know fast-forward through
a couple like simple parts or repeats
and then I'll show my solutions to the
other two exercises and then also the
beginning of section 3 is github we'll
be doing that next week and I've already
started that but it starts off with an
exercise so I just figured I'd end it
with with section two and they just pick
up next week
I wanted I'm gonna make section three
one whole video for next week so I have
a lot I have a lot of work to do so
let's get to it and lecture 18 I
discussed this two videos ago a little
bit it's functions functions aren't
really that difficult where we're at
right now you know you're gonna be able
to use more complex functions use it
with uh with other problems down the
line but right now with the problems
that we're doing it's not really all too
difficult and although although I've
already like known it know a little bit
about functions from C++ mark puts into
really good terms and it's very very
helpful the way he teaches and it
definitely help help functions of what
they're all about sticking my brain
better the way he explained it which I
just saying a lot lecture 19 we went
over bowls and conditional logic and the
main things to take note are the
conditionals or whatever they're called
so right here you can see equal equal so
this equal
is when you compare two things these are
all the operators I guess I'll call them
let's go to the computer and I'll show
you I'll give you guys an example of
each one so here are some examples of
the boolean operators so before we get
into that just take a look up here this
is your guide so equal two is two equal
signs not equal to is exclamation point
you'll sign greater than and less than
and all these are kind of
self-explanatory so we did first is we
made a variable named bank balance bank
balance egos $400 and item two by equals
$500 so what we do is if bank balance is
greater than or equal to item two by
then we could purchase the item in this
case we can't so imagine if this if this
was 500 and this was 400 then we would
be able to do that but we can't because
we don't have enough money so this is
just giving you a real-world example for
greater than if item 2 by is greater
than bank balance then what you print
out is say you don't have enough money
or go get a job or something like that
because you don't have enough money to
buy what you're trying to buy so you're
gonna get rejected unless you know you
you go negative in your bank count but
who wants that so that's an example of
creator than or equal to and then
greater than and then and then equal to
if item 2 by equals bank balance we'd
probably want to let those people know
that they have $0 so if it was exactly
500 like this up here 500 500 then it
would print out this and we would want
to let them know that their bank balance
is now zero and then I couldn't find a
good a not equal to on that one I wanted
to give you guys a better example so say
you're in a in a library or something
like that and you're look trying to
check out a book and you search on there
I forgot what it's called but that that
library software that that you're able
to check all the books in and search and
see if it's in stock and whatnot so here
we have two book titles the real book
title is Think and Grow Rich the title
that you typed in is think and go reach
and maybe you misheard it you misspelled
it you're thinking
but you spelled it wrong so if book
title one does not equal book title two
we have to let the person know that
books not found check your spelling so
there's different ways to say like if
you're if you're close you know if
you're this close and it would recommend
this but we're just doing the basics
we're if it's not equal then the book is
not found we can't find the book that
you're searching for check your spelling
and those are the examples of those and
you'll understand you understand if it's
less than or equal to just to say we
switch these two around or we can even
just go like this but like I said yeah
we would have to switch these two around
so forget about that so that's how those
boolean operators work and right now
we're going to get in to exercise the
first one for this video functions so
the first thing to do create a new Xcode
playground done create a function named
add that takes two parameters of type
double and returns the sum of the two
numbers so we want to create a function
named add that's alright add we can name
these num1 and then i said it wants to
be a double so we do like that and then
we do num2
you can name whatever you want so that's
just what i want to name this for sake
of argument and then within it what did
i want us to do you want us to return
the sum of the two numbers so we could
do return num1 plus num2
and you don't even call or anything so
that should be right right
no maybe not maybe not right what I have
to send this over like this make that a
double like that so that should work
right I don't see this returning
anything well let's go on to the next
deal sometimes this is slow for me so I
just have to keep it moving and then
I'll come back to it a bit so that was
question to complete right so question 1
question 2 now question 3 create a
function name subtract that takes two
parameters of type integer
integers and returns difference of the
two numbers so basically we're just done
the same thing by subtracting let me
just return it
same exact ways last time but
subtracting but what do they want us to
do returns a difference of the two
numbers so oh that's right what we
didn't do is assign numbers to the
actual variable correct see I'm still
having trouble with this reader over
here because it's just this hello
playground by the soffits do not
hello playground so what we're going to
do is we're going to exit out of this
and then and then I'm going to paste it
back in hopefully that'll fix it so now
it shouldn't have I don't think you
should have anything because we haven't
declared num1 to be any type of number
except for a double
so basically the next thing we do is the
same exact thing but we multiply floats
and then after that we're going to
divide double so let's just hurry up and
do that already so because this is
really not a difficult
and then we're gonna do next is all this
functions all this what does it say all
of those functions in pass different
values into the parameters ensure they
are producing the correct results this
is a miss I don't know this may be a
misprint but so basically we're giving
all these numbers okay so it looks like
it wants us to assign these it wants us
to reference or call these functions
into a situation where we are actually
declaring the numbers so we can use var
or let let's just do left but make it
nice and neat let I don't think I can
use add let's do let plus and but these
are doubles so actually just not do that
let's do three point three I think I
have to put equal sign there maybe yeah
okay and now it goes back up and says oh
this is the last thing that I'm wanting
them to equaled within this function we
just do that with all let -
and make num2 equal seven and we'll see
that this doesn't work because it needs
to be an integer integer to an integer
so if we take these out it works so 8 8
- 7 8 - 3 even if we put it double over
here it won't work because obviously
they're declared to be an integer hasn't
changed yet till I get out of there as
you can see there's errors error here
and just didn't change our here 3 foot
can only hold like so many bytes it's
only it's only so many bytes worth while
the double is is a lot bigger than a
float so normally they say use a use a
double some people would like to say oh
no I want to use a float because it's
going to use the less memory well it's
not worth in the long run I mean if you
need to change it that means you have to
go back and change the float and the
only reason you need to do that is if
there's an error in your code so
so I think that's it they just want us
to throw values in there make sure it
worked each and every way make sure that
double worked right or major first of
all made sure that our function works
right made sure that we declared it
correctly in order for you know two
doubles to come out as a double and in
order for us to only be allowed to put
in doubles there as well as integer
float and double again now lecture 21 is
constants and logical operators where
before we had like boolean operators
where they had the two equal signs
greater than greater than equal to less
than less than or equal to but now we
have the logical operators which are and
or and not so and is the double
ampersand or is double pipes and not is
exclamation point before the word or the
this is how you may know how to do it
you may know how to do it like this if
yadda-yadda
is not equal to this then you know you
do whatever is in the parentheses or you
know you can do else
yeah yada the better way to do that is
like this so you just put the
exclamation point before this word and
you don't even have to worry about that
and it means exactly the same thing but
it's a lot simpler you know you save you
know what six characters of code but it
works out better that way later down the
line just it's better practice
supposedly I know I kind of have chicken
scratch but you know I'm sitting there
listening and I'm just writing it down
real quick and it's a it's it it's what
works for me you know I don't need to
exactly I know what I write so I can
kind of go back here and just reference
it I'm not going to stay here and if
allowed entry does not know and that's
the thing about learning you have to
find what works for you you have to find
that's about being tall with anything
you know we're not just being tall with
anything but whatever you may do you
know if you're putting together a desk I
may do it differently than you but if it
gets done either way you know one may be
more efficient but if you
gonna have more fun or if it's gonna be
better or easier for you to do it one
way then another way then you have to do
it that way so you have to learn how to
adapt to certain situations in your own
way you can't always just learn from
somebody else and then just regurgitate
everything that they just taught you you
have to you have to figure out ways for
you to use it so it stays up here and so
that it translates onto the paper or
onto your computer in a way that you
want to portray it so just a little
tidbit of information there
you