Compare commits

...

3 Commits

Author SHA1 Message Date
87d8246050 final 2022-10-12 17:56:38 +02:00
8950f8d153 added limits 2022-10-12 17:48:33 +02:00
834a48175f prototype upload 2022-10-12 14:26:37 +02:00
14 changed files with 372 additions and 0 deletions

13
ATM/.idea/compiler.xml Normal file
View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<annotationProcessing>
<profile name="Maven default annotation processors profile" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<module name="ATM" />
</profile>
</annotationProcessing>
</component>
</project>

7
ATM/.idea/encodings.xml Normal file
View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
</component>
</project>

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RemoteRepositoriesConfiguration">
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Central Repository" />
<option name="url" value="https://repo.maven.apache.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Maven Central repository" />
<option name="url" value="https://repo1.maven.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="jboss.community" />
<option name="name" value="JBoss Community repository" />
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
</remote-repository>
</component>
</project>

14
ATM/.idea/misc.xml Normal file
View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="MavenProjectsManager">
<option name="originalFiles">
<list>
<option value="$PROJECT_DIR$/pom.xml" />
</list>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="openjdk-17" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

6
ATM/.idea/vcs.xml Normal file
View 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>

101
ATM/.idea/workspace.xml Normal file
View File

@ -0,0 +1,101 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AutoImportSettings">
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="f370439b-3b86-4211-acf9-0118b90c4643" name="Changes" comment="added limits">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/org/example/ATM.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/org/example/ATM.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/target/classes/org/example/ATM.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/org/example/ATM.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/target/classes/org/example/Card.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/org/example/Card.class" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="Class" />
</list>
</option>
</component>
<component name="Git.Settings">
<option name="RECENT_BRANCH_BY_REPOSITORY">
<map>
<entry key="$PROJECT_DIR$/.." value="PrototypWiktor" />
</map>
</option>
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/.." />
</component>
<component name="MarkdownSettingsMigration">
<option name="stateVersion" value="1" />
</component>
<component name="ProjectId" id="2FuMbGcqabWerHQKDeZ8WEmFMGw" />
<component name="ProjectLevelVcsManager" settingsEditedManually="true" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">{
&quot;keyToString&quot;: {
&quot;RunOnceActivity.OpenProjectViewOnStart&quot;: &quot;true&quot;,
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
&quot;SHARE_PROJECT_CONFIGURATION_FILES&quot;: &quot;true&quot;,
&quot;settings.editor.selected.configurable&quot;: &quot;preferences.keymap&quot;
}
}</component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="f370439b-3b86-4211-acf9-0118b90c4643" name="Changes" comment="" />
<created>1665337585789</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1665337585789</updated>
</task>
<task id="LOCAL-00001" summary="added limits">
<created>1665589713998</created>
<option name="number" value="00001" />
<option name="presentableId" value="LOCAL-00001" />
<option name="project" value="LOCAL" />
<updated>1665589713998</updated>
</task>
<option name="localTasksCounter" value="2" />
<servers />
</component>
<component name="Vcs.Log.Tabs.Properties">
<option name="TAB_STATES">
<map>
<entry key="MAIN">
<value>
<State>
<option name="FILTERS">
<map>
<entry key="branch">
<value>
<list>
<option value="origin/PrototypWiktor" />
</list>
</value>
</entry>
</map>
</option>
</State>
</value>
</entry>
</map>
</option>
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="prototype upload" />
<MESSAGE value="added limits" />
<option name="LAST_COMMIT_MESSAGE" value="added limits" />
</component>
<component name="XSLT-Support.FileAssociations.UIState">
<expand />
<select />
</component>
</project>

25
ATM/pom.xml Normal file
View File

@ -0,0 +1,25 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>ATM</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>ATM</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,87 @@
package org.example;
import java.util.Arrays;
import java.util.Objects;
import java.util.Scanner;
public class ATM
{
public static void main( String[] args )
{
Scanner scanner = new Scanner(System.in);
int cash = 10000;
Card[] cards = new Card[3];
cards[0] = new Card(1, "credit", "0001");
cards[1] = new Card(2, "debit", "1110");
cards[2] = new Card(3, "debit", "1111");
cards[2].addFunds(1000000);
while(true){
System.out.println(Arrays.toString(cards) + "\nWsuń kartę(podaj id):");
int index = scanner.nextInt()-1;
System.out.println("brrrrrrrrr... \n Proszę podać PIN:");
if(!Objects.equals(scanner.next(), cards[index].getPIN())){
System.out.println("Zły PIN");
continue;
}
boolean running = true;
while(running) {
System.out.println("""
Wybierz co chcesz zrobić:
[0]Sprawdź stan konta
[1]Wypłać
[2]Wpłać
[3]Przelej
[4]Wygeneruj kod do telefoni pre-peidowej
[5]Koniec""");
int insertedAmount;
switch (scanner.nextInt()) {
case 0 -> System.out.println(cards[index].getFunds());
case 1 -> {
System.out.println("Wprowadź kwotę:");
insertedAmount = scanner.nextInt();
if (cards[index].isLimitExceeded(insertedAmount)) {
System.out.println("Niewystarczająca ilość środków");
}
else if(cash-insertedAmount<0){
System.out.println("nie wystarczająca ilość środków w maszynie");
}
else {
cards[index].withdrawFunds(insertedAmount);
System.out.println("ksz ksz ksz ksz...");
}
}
case 2 -> {
System.out.println("Wprowadź kwotę:");
insertedAmount = scanner.nextInt();
cards[index].addFunds(insertedAmount);
System.out.println("am am am...");
cash+=insertedAmount;
}
case 3 -> {
System.out.println("Wprowadź id karty do przelewu:");
int transferCard = scanner.nextInt();
System.out.println("Wprowadź kwotę:");
insertedAmount = scanner.nextInt();
if (cards[index].isLimitExceeded(insertedAmount)) {
System.out.println("Niewystarczająca ilość środków");
} else {
cards[index].withdrawFunds(insertedAmount);
cards[transferCard - 1].addFunds(insertedAmount);
System.out.println("siup siup siup...");
}
}
case 4 -> {
System.out.println("Wprowadź kwotę:");
insertedAmount = scanner.nextInt();
cards[index].withdrawFunds(insertedAmount);
System.out.println((int) Math.floor(Math.random() * (999999999 - 111111111 + 1) + 111111111));
}
case 5 -> running = false;
}
}
}
}
}

View File

@ -0,0 +1,9 @@
package org.example;
public class App
{
public static void main( String[] args )
{
System.out.println( "Hello World!" );
}
}

View File

@ -0,0 +1,52 @@
package org.example;
public class Card {
private final int id;
private final String type;
private String PIN;
int balance;
public String getType() {
return type;
}
public String getPIN() {
return PIN;
}
public int getFunds() {
return balance;
}
public void addFunds(int amount){
this.balance += amount;
}
public void withdrawFunds(int amount){
this.balance -= amount;
}
public boolean isLimitExceeded(int amount){
if(this.balance-amount<0){
return true;
}
return false;
}
public Card(int id, String type, String PIN) {
this.id = id;
this.type = type;
this.PIN = PIN;
this.balance = 0;
}
@Override
public String toString() {
return "Card{" +
"id=" + id +
", type='" + type + '\'' +
", PIN='" + PIN + '\'' +
", balance=" + balance +
'}';
}
}

View File

@ -0,0 +1,38 @@
package org.example;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
/**
* Unit test for simple App.
*/
public class AppTest
extends TestCase
{
/**
* Create the test case
*
* @param testName name of the test case
*/
public AppTest( String testName )
{
super( testName );
}
/**
* @return the suite of tests being tested
*/
public static Test suite()
{
return new TestSuite( AppTest.class );
}
/**
* Rigourous Test :-)
*/
public void testApp()
{
assertTrue( true );
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.