Subtitles for Java Bank App Full Twitch Stream

  Pause sub
ok we're going to go ahead and
get started because we have
about an hour to see how far we
can get into doing this
development so let's go ahead
and look first at the UML
diagram one more time we see
that we have the six classes in
here we have checking and
savings which are two classes
that inherit from account and
then we have our menu class our
bank and our customer i'm going
to actually start off by
creating all of my classes in
that beans and then i'm going to
go through and do the code for
each individual class so let me
switch back over here to
NetBeans and i'm going to create
a new project it's going to be a
java application and i'm going
to call it tanked app and the
first thing I'm going to do is
I'm going to add all of my
classes so I have a menu class I
have a bank class I have a
customer class an account class
checking class and a savings
class and by making all of my
classes first i'm not going to
have any issues whenever I try
to reference them in my code i'm
also going to go into checking
and add that it extends the
account class and I'm gonna go
into savings and add that it
extends the account class so now
already we have all six classes
created and we have the
structure outline for an entire
program so now we can begin on
actually coding it so in the
menu on that UML diagram we had
noted that we have two instance
variables so i'm going to create
my instance variables one of
which is the scanner that i'm
going to call keyboard and
that's going to take system . in
its giving me an error because i
need to go ahead and add the
import java.util.scanner once i
do that that problem goes away
another instance variable that
the menu is going to have is a
bank object and that's just
going to be a new bank remember
the bank is what has the list of
customers so the menu keeps
track of that Bank which
contains the list of customers
that were allowed to do
operations on in the future if
we wanted to replace this
command line version with a
graphical interface it would
just be a matter of writing the
menu instead of having to go
back and edit each class that's
the reason that we're doing this
so i have my instance variables
there and then I'm gonna go
start outlining my methods
well i know i'm going to have a
public static void main because
the menu is where my program
executes from and then I have a
few different options according
to the UML diagram we used a
print menu method but in class
we actually talked about run
menu which i think is a better
option
so we're going to make a public
void run menu
it doesn't take any parameters
and inside of run menu what it's
going to do is it's going to
have a well its first going to
print our header out and then
it's going to have a while loop
well not exit we're going to
print our menu then we're going
to get a choice and then we're
going to perform an action based
on the choice that was selected
so I'm getting an error on a few
of these parts
let's start off with exit I'm
getting an error on exit because
it's a variable that I haven't
declared so another instance
variable appear that we didn't
identify before but we found out
we need now is a boolean called
exit by default it's set to
false so I don't need to set a
value for it and now i have
print header print menu get
input and perform actions which
are all just methods that
haven't been created
I can just click the little
lightbulb next to it and it will
create the methods for me that
way I don't have to do all the
typing
so now i have those methods i'm
going to start off with . header
print header is just a few
combinations of s out that are
going to print out a little menu
that you see whenever you
actually loaded up here so
hopefully we can manage to get
through this entire project in
an hour and then you can go back
and reference this video i'm
going to upload it to youtube
once we get it finished so I
have my square mock-up here for
my banner now I need to just
start typing somewhere in it and
try to Center the text so i'm
going to say welcome to mr.
these awesome bank app
alright so that's our header if
i was to run this right now
would print out that header and
then it would error out because
print menu doesn't exist
print menu is very similar to
print header it's just a couple
s out statements
geez ok so we're going to say
please make a selection and then
we're going to have our options
we have option 1 which is going
to be to create a new account
then we'll have option two which
will be to make a deposit option
3 which will be to make a
withdrawal option for which will
be two lists account balance
list account balance and and the
last one is going to be exit
alright so that's our print
header and our print menu
options get input is a method
that actually reads input from
the keyboard and returns it back
to this end choice right here so
get input is going to be a
method that starts off with by
let's see when we call it here
we've already printed out our
menu and we're waiting on just
user input from the keyboard so
I guess what we probably want to
do in here is start off with a
try-catch block and we're going
to catch a number format
exception
we're going to call it II and so
let's see what we do here we say
we're going to have our integer
choice equals negative 1 then
we're going to try to get a
value for it so we're going to
say choice equals integer .
percent from the keyboard . next
line it's going to attempt to
take what you type in the
keyboard convert it to an
integer and stored in choice
we're going to catch that if it
fails to do that if it fails to
do that we're going to print out
message it says invalid
selection numbers only please
and then I want to check if my
choice is less than zero or my
choice is greater than for it's
outside of our actual range
because our range is 0 1 2 3 4
so if out is the outside of that
i'm going to do in SF that says
choice outside range please
choose again and then what I'm
going to do is add a while loop
around this because if I don't
have a while loop around this is
going to run one time so I'm
actually going to do a do while
loop because that guarantees
that it will execute at least
one time so here i have my do
and then I need a while
condition my while conditions
actually going to be the same
thing as this right here and the
last problem is that i need to
return choice
alright so we have get input
which sets our choice to
negative 1 it has a do-while
loop which is guaranteed to run
at least one time it's going to
try to get an integer from the
keyboard if you enter something
incorrectly it will say invalid
selection numbers only please if
you enter choices outside the
acceptable range it'll say
choice outside of range please
choose again and let's actually
add one more s out here let's do
an SF that says instead of print
lines just to apprentices enter
your choice
there we go and the last thing
we need to do is our perform
action and then we have our
basic menu structure we can
start working on the more
specific options so for perform
action we take a choice and we
want to do a switch with that
choice we have a case that it's
zero the case that it's one case
that it's too
case 3 and case for we also need
a default case but if that
occurs then we should say
unknown error has occurred
because we don't know what
happened in case 0 we want to s
out
thank you for using our
application and then we want to
go ahead and exit the way you
exit the program is system .
exit it takes a integer if you
put zero it means standard exit
if you put any other number then
it can cause it to throw an
error like the program failed in
a way it shouldn't have so down
here for example when an unknown
error occurs i could exit and
throw a code so that you know
that a problem has occurred and
you have an error code to debug
with and after each case you
have to put a break statement
and if you don't put a break
then it falls through its kind
of like a hotel or something if
you match the first case and you
don't have a break
you'll fall through the floors
until you get to the very last
one or until you encounter a
break
ok so let's review real quick we
have created a new account make
a deposit make withdrawal enlist
account balances so case one
will be create an account and
then we need a break
k stew will be to make a deposit
and then we need a break
case 3 will be to make a
withdrawal and then we need a
break and the last case would be
to list balances and a break and
we're just going to make sure
that this works before we go
forward cases build successful
it doesn't work it because i
haven't actually written the
code inside of Maine so in Maine
need to say menu menu equals new
menu that's creating an object
of this class and then I need to
tell my menu to run so now when
I run it i get my welcome menu
that says welcome to mr. B's
bank awesome bank app please
make your selection and I can
choose something like create a
new account
obviously after i choose create
a new account since i don't have
anything happening it's just
going to reprint the menu which
is about where we got two in
class so now i have to actually
make my options do something so
i'm going to start off with
creating a new account make a
deposit make withdrawal and less
balances if I uncomment all of
them i get errors because those
methods don't exist so I'm going
to add those methods
ok so now I have this methods i
have a create an account make a
deposit make withdrawal and
lists balances we're going to
start having to rely on other
classes shortly so we are going
to go through those other
classes and start adding co2
them but let's go ahead and do
what we can and create an
account until then I know that
I'm going to need a string for
my first name my last name my
social security number and i
will need a double for my
initial deposit
ok so i need to read and all of
those first three details and
the initial deposit we're not
going to do any error checking
for first name last name and
social security number if
someone entered those
incorrectly that's their problem
for an initial deposit though we
will check to make sure it falls
in the acceptable range for the
type of account they want to
open
and that's actually one more
thing we need we need to know
the account type whether it's
checking or savings so I'm going
to start off asking if they want
checking or savings and then
I'll get their information so
i'm going to say wow
let's see what's the way we want
to do this we have to check that
account type is either equal to
checking or savings so let's add
a boolean called valid and set
it equal to false and say while
not valid
we're going to SL please enter
and account type and let's just
do print okay and then we will
read it in so we'll say account
type equals keyboard . next line
so now i have please enter an
account type checking or savings
they'll enter it and i'll read
it in and I'll say if account
type dot equals ignore case
checking or account type dot
equals ignore case savings then
we set valid equal to true that
will end our loop if it's not we
will s out
invalid account type selected
please enter checking or savings
alright so now we're outside of
the while loop that we initially
had set up there that verifies
that they only can create an
account of type checking or
savings if they enter anything
else we won't let it continue
the next step is to read in
first name last name and social
security number
like I said we're not going to
do any validation
those were just going to read
them directly in so we'll say
please enter your first name and
I'm going to make these all
print statements instead of
front-line so first name will be
equal to keyboard . next line
another s out saying please
enter your last name
some people chose to read the
first name and last name in
together as just a name that's
fine you don't really have to
have them be separate but if you
choose to do them separate than
that that is that does give you
slightly more flexibility in
terms of what you can actually
do in the end because you can
print out just the first name or
their last name instead of
everything and the last one we
need is please enter your social
security number
alright so we've figured out if
they want checking or savings
we've gotten there first name
last name and social security
number now we need to do the
initial deposit we do already
have a boolean called valid so
we can reuse it if we want we
can say valid equals false and
say wow
not valid we say SL please enter
an initial deposit and let's
just do a print so here's the
part where we may end up with an
issue if you remember get input
returns back a choice but it
handles that integer . percent
so if they accidentally put in
something that's not a valid
number we actually catch it here
and say something to them we
have to do something very
similar in here so i'm going to
put a try-catch block again and
in here we're actually going to
read our initial deposit as a
double dot parts double from
keyboard . next
and if we have to catch a number
format exception here it's
because they again entered words
instead of numbers so we'll say
deposit must be a number
ok so that handles actually
reading it now we need to handle
as if it's not the right amount
so if account type dot equals
ignore case checking then if
deposit is less than 100 then s
out that deposit is called
initial deposit guys alright so
if our account type so it's
saying account type may not have
been initialized we know that it
will be up here but it's unhappy
about it so we'll set it to an
empty string to begin with
initial deposit it says the same
thing so we'll go ahead and set
it equal to 0 as well that gets
rid of the areas that they were
having they were just warning
messages basically saying it's
possible that they don't have a
value because we're forcing
people to enter values that we
know they will but to make the
compiler happy will give them a
default value of empty string
and 0
alright so deposit must be a
number if initial deposits less
than a hundred then we print out
checking accounts require a
minimum of one hundred dollars
to open
k else
that would mean that we have
correctly entered an amount of
money here and so we can go
ahead and said valid equal to
true we want to do this same
check basically except as an
else if for savings and in the
case of savings
it's 50 so savings accounts
require a minimum of fifty
dollars to open and if it was a
savings account and initial
deposit was fifty dollars or
more it would be a valid true
and that would exit out so this
will keep going asking them to
enter an initial deposit until
they put a valid amount so we
have an account type first name
last name social security number
and the initial deposit so now's
the part where we can create an
account now so we have an
account that we will refer to
his account and then we'll say
if account type dot equals
ignore case checking then we do
one thing else will do another
the one thing we we do here is
we set account equal to a new
checking account and the
checking accounts going to need
not a new checking account
yeah new checking account
we're going to have to pass it
our initial deposit else our
account will be a new savings
and will also pass it
our initial deposit so now i'm
getting errors for both of these
because we haven't actually
created anything in those so
let's go ahead resolve these
errors and then we'll come back
and continue working here in
menu so I'm going to start by
going to account and i'm going
to add everything from our UML
diagram we said that we need a
private double called balance we
need a
private double called interest
and we needed an account number
so that's a private integer
called account number and then
for these we needed two methods
that need to exist and so for
balance and interest and account
number
not so much account but
not so much account number but
let's go ahead and say refactor
encapsulate fields and this adds
all the getters and setters for
us automatically so that we
don't have to type them account
number should be set whenever
the account is created and then
it should never actually get
changed
there's a few ways that we can
go through implementing that I
think that probably we can do it
an account let's do that let's
say let's go let's take the easy
way out we're going to say
private static and number of
accounts equals and we'll start
it off at a million and every
time you add a new account will
just add one on top of that
okay so we need a constructor
here for account and whenever
you create a new account it
needs to take let's see does it
take anything the balance the
interest rate are handled later
so again I guess we can say yeah
the interest is the same unless
your balance gets over a certain
amount and we'll handle that in
checking and savings
individually so really it's just
the account number so we will
have the account number be equal
to number of accounts
Plus so it sets it equal to a
million and then increases
number of counts by one so next
time the account will be a
million-in-one and that way we
have a constant counter going up
no account number will be the
same let's also get rid of these
getters and setters for let the
center will leave the get
account number but you don't
need to be able to set the
account number should never
change but balanced and get
interest there should exist so
we're good there
we have a constructor for
account and all it does is it
sets the account number is
balanced interest in and yet
balanced and interest will be
handled in checking and savings
so here in our checking class
what do we need to do well i
went ahead and gave them a
private static and not strength
called account type and i set it
equal to checking their checking
account and i'm going to copy
that same thing to savings here
except it will be for savings
all right now in checking i need
to create a constructor and the
constructor for checking account
takes a double for the initial
deposit and it needs to call the
parent not this calls super
super calls this one right here
which sets our account number
and then I'm going to have to
say this . set balance equal to
our initial deposit and then if
initial deposit is greater than
10,000 then set our interest
rate to five percent
else we set our interest rate to
2% alright and I think that's
really all that's involved in a
checking account and we do also
need a two-string method to
string if you remember is how
you can actually print out
details of it so i'm going to
overwrite that i'm going to do
an app override and it's going
to be public string to string
and in here I need to return a
string that's going to be
account type plus account and
then actually let's see what we
want to say let's print out
account type plus account type
count the backslash in on the
next line below it
let's print out your balance so
we'll say balance plus this .
get balanced actually it's due
account number first account
number
k then we'll do a balance and
the backsplash and then I'm
adding here just means go to the
next line so it will say the
account type and the account
number then the balance and then
I guess the interest rate
because that was worth $MONEY
bonus points and that's good
that's our two string method so
this is our checking account
that's about all we actually
need in there and our savings
account is actually really
similar
it may be possible to actually
abstract this little more but
we're not going to worry about
that right now so i'm going to
copy this two-string method
actually i'm going to copy all
of this code and then come over
to savings and paste it and all
I'm going to change is this
should say savings and down here
everything else is good so we're
going to leave that all like
that
we will need to hear an account
we need two more methods we need
withdraw and deposit now
remember that withdraw and
deposit are basically the same
when you make withdraw your
charge to certain amount when
you make a deposit your charge
to certain amount so let's go
ahead and add those down here
i'm going to make a public void
with draw it takes a double that
your amount and I'm going to
make a public void deposit takes
a double for our amount when you
make with the draw there's a
couple things when they check we
need to say if the amount plus 5
because we said there's a
five-dollar charge is greater
than our balance then you need
to print out a message that says
you have insufficient funds
now some of you asked could i do
an overdraft or credit system
this is where you would handle
that if they don't have enough
money you could tell them that
they can take a loan out on
credit or something like that
but if the amount plus 5 is
greater than the balance we need
to print out you have
insufficient funds and then i'm
going to return because we're
done running
um yeah that's when we can do it
will do that if it's not
insufficient funds then you can
go ahead and process it and so
will say balance minus $OPERAND
equals amount plus 5 and we will
print out you have withdrawn
plus the amount dollars and
incurred a fee of five dollars
and we can put a dollar sign
there that way it looks pretty
alright so you've withdrawn
blank amount dollars and
incurred a fee of five dollars
one more you now have a balance
of balance
ok so that's our withdrawal
method our deposit method is
very similar
we're just going to say if
amount is less than zero then we
print out you cannot deposit
negative money and then we
return from their otherwise it
means you've entered a positive
amount so we can go ahead and
deposit that amount the way that
you deposit it is that the
amount will be equal to the
amount plus the amount times the
interest rate it's not called
interest rate it's just called
interest
ok so amount times
interest
ok so amount times that's going to give us the
that's going to give us the
bonus that you get for making
deposit and so that's our new
amount and then you're just
going to finish off by saying
balance plus $OPERAND equals
amount and let's copy this text
here and have it say you have
deposited blank amount dollars
and say with and interest rate
of $MONEY plus interest plus
percent now we actually don't
want this to be interest because
let's see our interest is a
double so this should be to get
it to be a percentage you have
to multiply it by a hundred
because it's going to be like .
05 alright
yep and let's go ahead and give
our initial value if you don't
set it to anything it's an
initial value of two percent and
your balance is initially 0
alright that's our withdrawal
method that's our deposit method
i think we should be good there
for checking when you set your
interest you should set it to
0.05 and this one should set
interest to 0.02 because these
aren't percentages these are in
that while they are in
personnages as a double though
alright and then your interest
rate so get interest which is
from account right here should
probably return your interest
rate times a hundred so that you
get the actual percent number
and we'll put a percent symbol
on both of these
alright we have a checking or
savings the deposit amounts here
for deposit there's one more
thing we need to do if the
amount is less than zero you do
that right here we need to say
if amount so if amount actually
let's do this let's make a
method called check interest and
here we'll have a private void
check interest if our balance is
greater than 10,000 then $STREET
and Trish equals 0.05 else
interest equals 0.02 so just
each time that you make a
deposit or a withdrawal will
reset your interest rate and we
do have the initial interest
rate being said here let's make
this public and that way this
right here can just be a call to
this . check interest and that
helps reduce our code make a
little cleaner
alright so i think i count
checking and savings are
actually done we have everything
implemented inside of them
we have a touch bank customer
yet but if we come back here we
don't have an error on either of
these anymore so we do have an
account created at this point so
now what we have to do is we
need to create a customer so we
need to say customer customer
equals new customer and that's
going to need to take a first
name last name social security
number and our account that we
just created
ok and there were getting error
because our customer did not
have it so I told it to create a
constructor for me so I have a
constructor here now but i can't
set these values because i need
this . first-name equals first
name this . lastname equals last
name this . SN equals SSN and
this . account people's account
now all of them are giving the
errors because those fields
don't exist so i'm going to go
ahead and create all of these
fields right now it's setting
them to final which is ok if
they never change in this
particular case because of the
way our application is they
never do change so it's okay for
them to be final for our
customer what do we need our
customer needs a two-string
method so just like we did in
the other classes will do an ad
override and will say public
string to string and what will
happen here in our two string
method is we will return the
let's see let's say customer
information and let's put a
backslash end of the beginning
that'll give us a little bit of
buffering then we'll do plus and
we'll do first name + first
thing
last name
and then do sn+ ascend and then
the last part I'm going to do is
the account information if you
remember it prints all that
information out for me so i can
actually just say plus account
and what will happen is it will
do all of account it will call
the two-string method for the
account and all of that
information will print out below
it
ok and then I think that's
it
ok and then I think that's for customer so now we're so
for customer so now we're so
we've successfully created an
account and a customer so the
last step would be for our bank
to add the customer that we just
created and I'm getting an error
on that because the bank doesn't
have an ad customer method so
here in my bank
I told it to create an ad
customer method by clicking the
little light bulb and we can't
add a customer yet because we
need to create an array list of
customer called customers that's
equal to a new array list of
customer alright whenever you
say add customer it's just going
to say customers . oh we're
going to an error here because
we need to import
java.util.arraylist now i can
say customers . add the customer
that we added k and that should
get us going there if i want i
can go ahead and set a
breakpoint right here and then
when i run through it it'll come
up and it'll say they enter your
choice and i'm going to choose
to create a new account so
please into your account type if
i type garbage it should say
invalid account type
please enter checking or savings
i'm going to choose checking
please into your first name
I'm going to do mr. your last
name be social security
and please enter initial deposit
if i put twenty dollars it says
checking accounts require
minimum of a hundred dollars to
open so please enter an initial
amount i'll put a hundred and
now if we go check here in my
bank and my list of customers i
have one customer so you can see
your customer size equals one I
have one customer that's been
created it has an account and
the account has its account
types its number of accounts the
inherited values it's got a
balanced and interest rate and
an account number
okay so it looks like that
successfully works for creating
an account and we'd be able to
go over this over and over
creating more accounts now we
have more than just creating an
account but that was the main
part to get rid of
we got that out of the way so we
can start working on making a
deposit making a deposit is
pretty straightforward
we just need to figure out how
much they want a deposit and as
long as it is a positive
mountain actually in our deposit
a check that it's a possible
amount so we really don't even
have to do that we just need to
ask which account they want to
deposit it into and then try to
deposit it so here in menu we
have to figure out which account
they want to make a deposit to
so let's have integer account
equals select account
actually let's make that on the
bank to bank . now let's do it
here account equals select
account i was thinking we were
created on the bank but if we
created on the bank what's going
to happen is that when we go to
add a graphical interface later
we're going to have code that's
tangled up in our bank it really
shouldn't be so we're going to
make it out here and the menu
class that way it's not
congested and gross so arendt
account will be equal to select
account so that's going to be a
method we're going to create you
can create it now
just have a return 0 that will
return the account that we want
to make a deposit to so then
once we know the account we want
to make a deposit to we can say
thank . get customer let's say
get customer will pass an
integer which will be the
account and then on it we will
call the deposit method with the
amount that you've chosen to
deposit so make a deposit
actually takes double well we
can ask how much you want to
deposit so we need to do that so
which account do you want to use
and then we'll do is out how
much would you like to deposit
alright and they will enter
their amount and this
specifically takes a double so
we could add another while loop
if we wanted here just making
sure they enter a valid number
we're getting at the point
because we keep doing that it
might be worth breaking out into
its own method so I'm actually
just going to check it one type
one time i'm going to say double
amount equals 0 and say try
amount equals double dot R
stubble keyboard . next line so
that will try to read in from
the keyboard the amount that you
want to do if it catches a
number format exception and that
would mean that you had a
problem entering the amount and
if it does catch that then I'm
just going to set your amount
equal to 0 so if you enter
something like Hello it will do
0 in that way when this happens
over here if your amount is less
than or equal to 0 you cannot
deposit negative money that's
fine
alright so bank that get
customers giving me an error
because we don't have that
method so i click the little
light bulb and it added it
I don't want to return an object
i want to return a customer and
what this is going to do is
return the account or return the
customer at that position so we
will specifically return
customers . get account that
will return the customer from
that position in
list
let's see
yeah that's what we'll do ok and
so I also need one more thing
here to be here i need to have
the arraylist be returnable so
array list of customer called
get customers will return
customers
alright let's see what is
unhappy about here get customer
returns a customer
ok and then from customer i need
to get the account so we
actually do need to have a
hitter for account so let's add
a count get account return
account just to get her and so
what we're going to do is from
the bank we're going to get a
customer account and then we're
going to get their actual
checking or savings account and
then we're going to make a
deposit on it and our deposit
will be for whatever amount you
typed all right so we have our
bank we get our customer we get
the account of the customer and
then we make a deposit to it
k so the only thing we need to
do now is work on select account
and then this is this code is
going to be basically the same
for make withdrawal and less
balances so for select account
even one second let me get a
drink of water
ok so for select account we need
to do a realist of customer all
customers equals our bank . get
customers and then we need to do
is we need to have for integer i
equals 0
I less than customers will get
an error because we need to
import java.util.list ok so for
each customer that's in the list
we're going to print a line so
let's do an S out that says
select an account and then for
each customer we're going to
print out i plus 1 plus that and
then plus the customer . oh
sorry the customers . get I .
get first name so customer we
have our two string but we had
we need another method that's
similar to that it's just the
short account details on one
line so let's have it be
customer information already
don't want that I just want
first name + first name then
last name
oh and actually all of these
right here
I should be having a backslash
and added because otherwise
what's going to happen is
they're all going to be on the
same line
yeah I did it on all of these
but I didn't do it a customer
ok so this will be called to
string this will be called basic
info and it will return their
first name last name social
security number and the account
number plus account . get
account number and put spaces on
all of those alright let's see
if that makes a little better so
now we can get basic info that
should print it out for each one
and then we need to read in
which account they actually want
to do it on so again this is a
case for that try-catch where we
need to get the account they
want to say integer account
equals 0 try account
if they don't enter a correct
account i'm going to set it to
negative 1
ok so select account should ask
you to get all the customers
since they select an account
should put a line for each
customer and then we will say
this out please select our
please enter your selection and
let's just do that is a print
and you'll enter it and here
it's a select account and will
say if account is greater than
or equal to 0 then we will do
all of this now we need to
actually fix this because I
added one because i want
accounts to be starting labeled
at one so when they enter their
selection reaction is subtract
one from it so it would be minus
one so if they enter one their
choice is actually 0
ok so we should be able to make
a deposit now so if i run this
code if i choose to make a
deposit it will say please
select an account in your
selection and it doesn't really
matter what I put because we
need to handle that so select an
account for integer i equals 0
is that ok so we get our
customers here let's say if
customers . size is less than
zero
well let's do less than or equal
to 0 which means that there's no
customers
let's s out no at your
let's s out no customers at your
bank and then return negative 1
ok and so now if you run it and
you try to make a deposit
oh that was created account
let's stop that we try that if
you try to run it you make a
deposit will say no customers at
your bank and then it gives you
an option to make a selection so
i'm going to create an account
checking for myself and my
initial deposit will be a
hundred and twenty dollars then
i will say please make a
selection
I'm gonna make a deposit and now
you can see that it's printed
out my first name last name
social security number and
account number as one that i can
select and I can choose that I
want to select that one
how much would you like to
deposit let's deposit 20 more
dollars so it says you have
deposited 20.4 dollars so it's
not formatted properly but it
does at least deposit that
amount with an interest rate of
two percent i now have a balance
of a hundred and forty . for
which is accurate because i
deposited 20 and i had initially
deposited 220 with my two
percent interest rate that makes
it a hundred and forty dollars
and forty cents
obviously I don't have any new
lines printed out so this is all
squished together but at least
it is all there so let's see how
we can make this work for our
other ones we have to make a
deposit make a withdrawal unless
balances well i'm going to copy
the code from make a deposit and
paste it into make a withdrawal
because you need to select an
account if your account is
greater than or equal to 0 it's
going to be how much would you
like to withdraw and then you'll
give your amount people try to
parse it if you give an invalid
mount it will put 0 it'll get
your customer and then we need
to call withdraw on that amount
ok so now if i run this and you
choose to make withdrawal it
says no customers at your bank
to create a new account type
checking for CJ and I'm just
about vs 13 is my social
security hundred $23 i'm going
to try to make a withdrawal
select your account select
account one how much would you
like to withdraw all three
dollars says you have withdrawn
three dollars and courtesy of
five you now have a balance of a
hundred and fifteen well i had a
hundred 23-8 dollars because
that's the three of withdrawn in
the five dollar fee that gives
me a hundred and fifteen so
that works now and that means we
only have one more lists
balances and again it's going to
work very similar to the other
one so I'm just going to copy
and paste the code and here it's
going to say please select an
account if your account is
greater than or equal to 0
I can go ahead and list your
account details otherwise so
this is the only case where I
might print out a message
otherwise so if your account is
greater than or equal to 0 then
we'll get the account and then
we will
well we'll just do that will do
an S out of the account and that
should print out the details for
it
else we will say
so otherwise will do invalid
account selected so we do
actually need one other check
because right now i just
realized that if we run this and
I say to get an account checking
if i try to for example up with
it all right well let's make
another checking account while
I'm here for Dave packer so now
we know that we can create at
least two accounts but if i go
to make a deposit you see gives
me my two accounts to select
from and we can see they do have
separate account numbers but if
i was to enter an invalid
account like three it says how
much would you like to deposit
i'm going to get a crash so i
actually need a check here and
select accounts when I say
please into your selection you
select it now I catch if you
type something wrong but i also
need to say if account is less
than zero or account is greater
than $OPERAND customer . sighs
then I need to set account equal
to negative 1 see if that fixes
that bug so create a new account
checking
now if i make a deposit and I
select account for then it did
just exit out because it was an
invalid account number so if
account numbers less than 0 or
greater than size will do an
asset that says invalid account
selected all right so that
handles that and that would mean
here we don't need to say this
alright so i think that might be
our app let's try it out
let's do create an account to
make a checking account for CJ
Anderson this social security
number of 123456789 0 initial
deposit of a hundred and twenty
dollars and if i wanted to list
my account details i select for
that account and it prints out
the account type is a checking
account with an account number
of a million a balance of a
hundred twenty an interest rate
of two percent i was can create
another account let's make a
savings and i'm going to make it
for Dave Ward social security
number one two three two three
four three four five six initial
deposit of let's say 45 thousand
and then if i try to list his
account details we see that he
has an interest rate of five
percent because he has over ten
thousand dollars his account
numbers a million and one which
is not the same as mine so
that's good and if i wanted to
make a deposit $MONEY into my
account
I'm going to deposit 12,000
which means if I list out my
account now I should have a five
percent interest rate and i
don't so we have a problem here
try one more time just to make
sure
yes we have a problem here see
if we can figure that out real
quick and that'll be the last
thing we do in this stream
when I make a deposit
okay so check the interest
before I actually deposit the
money
well there's a couple ways that
we could do it we could force
check interest to take an amount
if we wanted
let's have check interest take a
double called amount and say it
balance plus amount is greater
than 10,000 so check here we're
going to pass the amount
ok and here will also pass the
amount actually here check
interest we are not passing
anything will pass 0 because the
balances already been changed
okay here when they check the
interest
they're going to put 0 and same
thing here 0 and so if i restart
this when i run it now I create
a new account
ok checking for CJ vs 1 2 3 2 3
123
please enter an initial deposit
of a hundred and twenty dollars
if i list my account details i
have an interest rate of
$PERCENT to $PERCENT now if I
make a deposit for this account
and I deposit hundred thousand
dollars when I list the account
details i have a five percent
interest rate let's try making
withdrawal from this account for
a hundred thousand dollars
oh I hit the wrong button
I want to make a withdrawal for
this account i want to withdraw
a hundred thousand dollars and
now if i try to print the
account details i have an
interest rate of $PERCENT to
$PERCENT which is correct that's
what it should be
so make a deposit make withdraw
create an account and lists
account details all are working
correctly 0 exits so i have a
complete working program here
all we have now to do is to make
everything look pretty so i will
make another video later it's
going to be how to actually make
everything look good i'm going
to go ahead and upload this
video over a youtube so anybody
who missed the stream or if you
need to go back and look at
something that I did
you'll be able to go review the
video and make those changes if
you have any questions leave
them in the comments section
over there YouTube and while
you're there make sure that you
like and subscribe to the video
and i will see you guys next
time
yeah

Share this subtitle


Description