Compare commits
2 Commits
master
...
prototypRa
Author | SHA1 | Date | |
---|---|---|---|
33a067edee | |||
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/DataReader.class
Normal file
BIN
bankomacik/out/production/bankomacik/DataReader.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.
97
bankomacik/src/DataReader.java
Normal file
97
bankomacik/src/DataReader.java
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
|
public class DataReader {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
Scanner input = new Scanner(System.in);
|
||||||
|
User[] users = new User[10];
|
||||||
|
users[0] = new User("Piotr", "Fronczewski", 1, 12345678, 2137, 0.0);
|
||||||
|
users[1] = new User("Szymon", "Michałowski", 2, 87654321, 9876, 0.0);
|
||||||
|
users[2] = new User("Bartosz", "Palka", 3, 12348765, 1234, 0.0);
|
||||||
|
System.out.println("Witamy w systemie naszego bankomatu!");
|
||||||
|
System.out.println("Proszę zalogować się na swoje konto, wpisz swój numer klienta");
|
||||||
|
int userNumber = input.nextInt();
|
||||||
|
DataReader loop = new DataReader();
|
||||||
|
loop.menu(users[userNumber]);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
Scanner input = new Scanner(System.in);
|
||||||
|
public void menu(User user){
|
||||||
|
|
||||||
|
boolean end = false;
|
||||||
|
while (!end){
|
||||||
|
logIn(user);
|
||||||
|
end = true;
|
||||||
|
}
|
||||||
|
System.out.println("Dziękujemy za używanie bankomatu.");
|
||||||
|
input.close();
|
||||||
|
//System.exit(status kodu)
|
||||||
|
System.exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void logIn(User user) {
|
||||||
|
int userNumber = user.getUserNumber();
|
||||||
|
int pin = 0;
|
||||||
|
|
||||||
|
boolean end = false;
|
||||||
|
while (!end) {
|
||||||
|
//user ma byc wyciagany na podstawie numeru konta a nie jako obiektu stworzonego w ramach danej klasy
|
||||||
|
if (user.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 (user.comparePIN(pin) == false){
|
||||||
|
System.out.println("Błędne hasło");
|
||||||
|
end = true;
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
System.out.println("Hasło wprowadzono poprawnie");
|
||||||
|
}
|
||||||
|
possibleOptions(user);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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");
|
||||||
|
|
||||||
|
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;
|
||||||
|
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ę
|
||||||
|
*/
|
89
bankomacik/src/User.java
Normal file
89
bankomacik/src/User.java
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
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) {
|
||||||
|
// amount nie moze byc ujemne, a po dodaniu do calego balanasu musi byc wieksze lub rowne 0
|
||||||
|
if (amount <= 0) {
|
||||||
|
System.out.println("Nie można dodać ujemnej kwoty lub 0.");
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
balance = balance + amount;
|
||||||
|
System.out.println("Stan konta po wpłacie wynosi: " + balance);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user