| JAVA-CREIAMO UN CODICE INSIEME |SIMULATORE BANCOMAT
Salve a tutti, ho deciso di intraprendere questo nuovo progetto perché lo ritengo molto interessante e perché penso possa servire a molti ragazzi che sono entrati da poco in questo mondo.
https://download.sublimetext.com/Sublime%20Text%20Build%203211%20x64%20Setup.exe
Una volta scaricato possiamo procedere con la creazione del nostro codice.
Il file che andremo a realizzare oggi sarà una simulazione di un bancomant,ci permetterà di inserire dei soldi, di ritirarli e di visualizzare le ultime transazioni.
INPUTSTREAMREADER=creazione flusso da tastiera;
BUFFEREDREADER=tamponamento flusso da tastiera;
Dopo aver fatto ciò iniziamo con l'inserimento delle nostre variabili, il consiglio che vi do è quello di lasciare un pò di righi così da poterle aggiungere dopo essendo all'inizio molte poche le variabili da inserire.
quindi procediamo inserendo una scritta creata in modo ASCII all'interno dei system out.
SYSTEM.OUT.PRINTLN= scritta stampata a schermo.
Adesso arriva la parte più complicata, iniziamo a implementare la parte logica.
Come detto prima questo codice ci permetterà di effettuare 3 scelte:
1)depositare
2)prelevare
3)visualizzare gli ultimi movimenti
quindi realizzeremo un menù di scelta con queste 3 scelte, questo sarà il risultato.
per acquisire la scelta del menù da effettuare creiamo 2 variabili, una di tipo int e una di tipo string per effettuare la conversione, a cui accoppieremo la scelta dell'udente attraverso "TASTIERA.READLINE()",quindi andiamo fino a sopra dove abbiamo lasciato i righi vuoi e inseriamo le 2 variabili, una cosa molto importante da sapere è che la conversione è obbligatoria, poiché il dato che noi andiamo ad acquisire di base è stringa, ma essendo inutile a noi, lo andiamo a convertire in intero tramite in converter.
una volta creato il menù e aver associato le 3 scelte a un numero, procediamo con la creazione dei vari casi.
Nel caso 1 ci chiede di depositare dei soldi, quindi per come fatto con l'acquisizione della scelta creiamo 2 variabili, una per tener conto di tutto il nostro saldo, una per l'acquisizione del dato che assoceremo alla tastiera.
Ci serviranno due array, che non sono altro che dei contenitori, un array lo utilizzeremo per tener traccia dei nostri depositi, entro un altro per tener traccia dei nostri prelievi, questi due array ci serviranno per i prossimi 2 casi, MOLTO IMPORTANTE è di aggiornare l'array ogni qual volta eseguiamo un operazione.
una volta finito il primo caso andiamo ad eseguire il secondo, che sono molto simili fra di loro, quindi andiamo a creare le 2 variabili del depositi, e.. invece di andare a sommare i soldi depositati con quelli che avevamo prima, andiamo a sottrarli grazie alla variabile creata prima per tener conto del nostro saldo.
Dopo di che andiamo ad aggiornare il nostro contatore ovvero il nostro array del prelievo e facciamo stampare a schermo sia il nostro saldo, sia i nostri movimenti.
Come ultimo step che riguardano il 3 e 4 caso, non ci resto altro che fare un for,per far cicalare tutto il nostro array e farlo stampare.
Nel terzo caso facciamo ciclare l'array dei nostri depositi, mentre nel quarto caso andiamo a far ciclare l'array dei nostri prelievi.
Come ultimissimo step, oserei dire anche quello più divertente, ci dirigiamo nel prompt,e dopo aver controllato se il nostro file non presentava errori, andiamo a effettuare i nostri controlli se il file funziona in modo corretto.
Hello everyone, I decided to undertake this new project because I think it is very interesting and because I think it can be of use to many guys who have recently entered this world.
https://download.sublimetext.com/Sublime%20Text%20Build%203211%20x64%20Setup.exe
Once downloaded we can proceed with the creation of our code.
The file we are going to make today will be a simulation of a bancomant,it will allow us to insert money, withdraw it and display the last transactions.
INPUTSTREAMREADER=creating flow from keyboard;
BUFFEREDREADER=printing flow from keyboard;
After doing that we start with the insertion of our variables, the advice I give you is to leave a few lines so you can add them later being at the beginning very few variables to be inserted.
so let's proceed by inserting a script created in ASCII mode inside systems out.
SYSTEM.OUT.PRINTLN= script printed on the screen.
Now comes the tricky part, let's start implementing the logic part.
As mentioned before this code will allow us to make 3 choices:
1)deposit
2)withdraw
3)view the last movements
so we will implement a choice menu with these 3 choices, this will be the result.
to acquire the choice of the menu to make we create 2 variables, one of type int and one of type string to make the conversion, to which we will couple the choice of the hearer through "KEY.READLINE()",then we go up to above where we left the lines want and we insert the 2 variables, a very important thing to know is that the conversion is mandatory, since the data that we are going to acquire basic is string, but being useless to us, we are going to convert it to integer through in converter.
once we have created the menu and associated the 3 choices with a number, we proceed to create the various cases.
Case 1 asks us to deposit money, so as done with the choice capture we create 2 variables, one to account for our entire balance, one to capture the data we will associate with the keyboard.
We will need two arrays, which are nothing but containers, one array we will use to keep track of our deposits, within another to keep track of our withdrawals, these two arrays will serve us for the next 2 cases, VERY IMPORTANT is to update the array whenever we perform an operation.
once we finish the first case we go to execute the second one, which are very similar to each other, so we go to create the 2 variables of the deposits, and.. instead of going to add up the deposited money with the money we had before, we go to subtract it thanks to the variable created before to account for our balance.
After that we go to update our counter that is our withdrawal array and have both our balance and our movements printed on the screen.
As a last step concerning the 3rd and 4th cases, all we do is to do a for,to cycle our whole array and have it printed.
In the third case we cycle the array of our deposits, while in the fourth case we go to cycle the array of our withdrawals.
As the very last step, dare I say also the most fun one, we head into the prompt,and after checking if our file had no errors, we go to do our checks if the file is working properly.
!discovery 30
Bellissimo post , presto ti raggiungerò anche io!
ahahaha ti aspetto, se ti serve una mano non esitare a contattarmi, lo ritengo un'argomento molto importante ma soprattutto divertente che è una cosa ancora più importante,grazie mille per il supporto.
Mi hai riportato indietro nel tempo tra i banchi dell'università :)
Bel post anche se a me servirebbe il codice per prelevare senza carta dal bancomat vicino casa mia :) !LOL
Scherzi a parte Bravo!
!PGM
!PIZZA
BUY AND STAKE THE PGM TO SEND A LOT OF TOKENS!
The tokens that the command sends are: 0.1 PGM-0.1 LVL-0.1 THGAMING-0.05 DEC-15 SBT-1 STARBITS-[0.00000001 BTC (SWAP.BTC) only if you have 2500 PGM in stake or more ]
5000 PGM IN STAKE = 2x rewards!
Discord
Support the curation account @ pgm-curator with a delegation 10 HP - 50 HP - 100 HP - 500 HP - 1000 HP
Get potential votes from @ pgm-curator by paying in PGM, here is a guide
I'm a bot, if you want a hand ask @ zottone444
lolztoken.com
The A-gull and B-gull weren't quite right.
Credit: reddit
@fraaaaa, I sent you an $LOLZ on behalf of @libertycrypto27
Use the !LOL or !LOLZ command to share a joke and an $LOLZ
(3/8)
ahahahaa va bene!! fra poco arriva anche quello👀
I gifted $PIZZA slices here:
@libertycrypto27(1/10) tipped @fraaaaa (x1)
Join us in Discord!