forked from s464969/apo-bankomat
first commit, prototype finished
This commit is contained in:
parent
d7e39ea89c
commit
d683c1d8d0
8
bankomacik/.idea/.gitignore
vendored
Normal file
8
bankomacik/.idea/.gitignore
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
6
bankomacik/.idea/misc.xml
Normal file
6
bankomacik/.idea/misc.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
8
bankomacik/.idea/modules.xml
Normal file
8
bankomacik/.idea/modules.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/bankomacik.iml" filepath="$PROJECT_DIR$/bankomacik.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
6
bankomacik/.idea/vcs.xml
Normal file
6
bankomacik/.idea/vcs.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
|
||||
</component>
|
||||
</project>
|
11
bankomacik/bankomacik.iml
Normal file
11
bankomacik/bankomacik.iml
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
BIN
bankomacik/out/production/bankomacik/Main.class
Normal file
BIN
bankomacik/out/production/bankomacik/Main.class
Normal file
Binary file not shown.
BIN
bankomacik/out/production/bankomacik/User.class
Normal file
BIN
bankomacik/out/production/bankomacik/User.class
Normal file
Binary file not shown.
7
bankomacik/src/DataReader.java
Normal file
7
bankomacik/src/DataReader.java
Normal file
@ -0,0 +1,7 @@
|
||||
public class DataReader {
|
||||
public static void main(String[] args) {
|
||||
System.out.println("Witamy w systemie naszego bankomatu!");
|
||||
Main loop = new Main();
|
||||
loop.menu();
|
||||
}
|
||||
}
|
93
bankomacik/src/Main.java
Normal file
93
bankomacik/src/Main.java
Normal file
@ -0,0 +1,93 @@
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class Main {
|
||||
Scanner input = new Scanner(System.in);
|
||||
User user1 = new User("Piotr", "Fronczewski", 1, 12345678, 2137, 0.0);
|
||||
|
||||
public void menu(){
|
||||
|
||||
boolean end = false;
|
||||
while (!end){
|
||||
System.out.println("Proszę zalogować się na swoje konto: ");
|
||||
logIn();
|
||||
end = true;
|
||||
}
|
||||
System.out.println("Dziękujemy za używanie bankomatu.");
|
||||
input.close();
|
||||
//System.exit(status kodu)
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
|
||||
public void logIn() {
|
||||
int userNumber = 0;
|
||||
int pin = 0;
|
||||
|
||||
boolean end = false;
|
||||
while (!end) {
|
||||
System.out.println("Wpisz swój numer klienta: ");
|
||||
userNumber = input.nextInt();
|
||||
if (user1.compareUserNumber(userNumber) == false){
|
||||
System.out.println("Nie ma takiego numeru klienta");
|
||||
end = true;
|
||||
break;
|
||||
} else {
|
||||
System.out.println("Numer klienta wprowadzono poprawnie");
|
||||
}
|
||||
System.out.println("Wpisz swój numer pin: ");
|
||||
pin = input.nextInt();
|
||||
if (user1.comparePIN(pin) == false){
|
||||
System.out.println("Błędne hasło");
|
||||
end = true;
|
||||
break;
|
||||
} else {
|
||||
System.out.println("Hasło wprowadzono poprawnie");
|
||||
}
|
||||
possibleOptions(user1);
|
||||
}
|
||||
}
|
||||
|
||||
public void possibleOptions(User user) {
|
||||
boolean end = false;
|
||||
while (!end){
|
||||
System.out.println("Aby wybrać opcję wciśnij klawisz odpowiadający danej cyfrze.");
|
||||
System.out.println("Możliwe opcje do wyboru: ");
|
||||
System.out.println("1 - sprawdź stan konta");
|
||||
System.out.println("2 - wpłać środki na konto");
|
||||
System.out.println("3 - wyjdź z systemu bankomatu");
|
||||
System.out.println("4 - przeloguj się na inne konto");
|
||||
|
||||
int option = input.nextInt();
|
||||
|
||||
switch(option) {
|
||||
case 1:
|
||||
System.out.println("Twój stan konta wynosi: " + user.getBalance());
|
||||
break;
|
||||
case 2:
|
||||
System.out.println("Wpisz ile środków chcesz wpłacić na swoje konto: ");
|
||||
double sum = input.nextDouble();
|
||||
user.deposit(sum);
|
||||
break;
|
||||
case 3:
|
||||
System.exit(0);
|
||||
break;
|
||||
case 4:
|
||||
end = true;
|
||||
break;
|
||||
default:
|
||||
System.out.println("Wybrano błędną opcję. Wybierz jeszcze raz.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Należy zbudować oprogramowanie wykorzystywane do obsługi bankomatu. Bankomat po
|
||||
włożeniu karty elektronicznej (kredytowa, płatnicza, bankomatowa) oraz weryfikacji
|
||||
posiadacza karty (sprawdzenie PIN), powininen wydawać kwotę pieniędzy. Bankomat
|
||||
powinien umożliwiać deponowanie pieniędzy, zakup kodów do telefonii pre-paidowej,
|
||||
sprawdzenie stanu konta oraz dokonywanie operacji przelewu dla użytkowników,
|
||||
którzy w swoim banku wystąpili o tego typu usługę
|
||||
*/
|
83
bankomacik/src/User.java
Normal file
83
bankomacik/src/User.java
Normal file
@ -0,0 +1,83 @@
|
||||
public class User {
|
||||
private String firstName;
|
||||
private String lastName;
|
||||
private int userNumber;
|
||||
private int cardNumber;
|
||||
private int pin;
|
||||
|
||||
private double balance;
|
||||
|
||||
public User(String firstName, String lastName, int userNumber, int cardNumber, int pin, double balance) {
|
||||
this.firstName = firstName;
|
||||
this.lastName = lastName;
|
||||
this.userNumber = userNumber;
|
||||
this.cardNumber = cardNumber;
|
||||
this.pin = pin;
|
||||
this.balance = balance;
|
||||
}
|
||||
|
||||
public User() {
|
||||
}
|
||||
|
||||
public String getFirstName() {
|
||||
return firstName;
|
||||
}
|
||||
|
||||
public void setFirstName(String firstName) {
|
||||
this.firstName = firstName;
|
||||
}
|
||||
|
||||
public String getLastName() {
|
||||
return lastName;
|
||||
}
|
||||
|
||||
public void setLastName(String lastName) {
|
||||
this.lastName = lastName;
|
||||
}
|
||||
|
||||
public int getUserNumber() {
|
||||
return userNumber;
|
||||
}
|
||||
|
||||
public void setUserNumber(int userNumber) {
|
||||
this.userNumber = userNumber;
|
||||
}
|
||||
|
||||
public int getCardNumber() {
|
||||
return cardNumber;
|
||||
}
|
||||
|
||||
public void setCardNumber(int cardNumber) {
|
||||
this.cardNumber = cardNumber;
|
||||
}
|
||||
|
||||
public int getPin() {
|
||||
return pin;
|
||||
}
|
||||
|
||||
public void setPin(int pin) {
|
||||
this.pin = pin;
|
||||
}
|
||||
|
||||
public double getBalance() {
|
||||
return balance;
|
||||
}
|
||||
|
||||
public void setBalance(double balance) {
|
||||
this.balance = balance;
|
||||
}
|
||||
|
||||
boolean comparePIN(int password){
|
||||
return pin == password;
|
||||
}
|
||||
|
||||
boolean compareUserNumber(int number){
|
||||
return userNumber == number;
|
||||
}
|
||||
|
||||
boolean deposit(double amount) {
|
||||
balance = balance + amount;
|
||||
System.out.println("Stan konta po wpłacie wynosi: " + balance);
|
||||
return true;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user