Główny plik Main
This commit is contained in:
parent
d62959eaa8
commit
91f0fab0da
239
wmiproject.java
239
wmiproject.java
@ -1,120 +1,119 @@
|
|||||||
package wmiproject;
|
package wmiproject;
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import org.json.simple.JSONObject;
|
import org.json.simple.JSONObject;
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
|
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
|
|
||||||
public class Wmiprojectclass {
|
public class Wmiprojectclass {
|
||||||
|
|
||||||
public static void main(String[] args)
|
public static void main(String[] args)
|
||||||
|
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
//TEST PESELI
|
//TEST PESELI
|
||||||
Testy test = new Testy();
|
Testy test = new Testy();
|
||||||
System.out.println(test.PrzetestujPeselValid());
|
System.out.println(test.PrzetestujPeselValid());
|
||||||
//
|
//
|
||||||
var filepath = "C:\\Temp\\testowy\\";
|
var filepath = "C:\\Temp\\testowy\\";
|
||||||
//TEST ŚCIEŻKI PLIKU
|
//TEST ŚCIEŻKI PLIKU
|
||||||
Testy test2 = new Testy();
|
Testy test2 = new Testy();
|
||||||
test2.PrzetestujPliki(filepath);
|
test2.PrzetestujPliki(filepath);
|
||||||
|
//
|
||||||
//
|
var n=0;
|
||||||
var n=0;
|
Timestamp timestamp = new Timestamp(System.currentTimeMillis());
|
||||||
Timestamp timestamp = new Timestamp(System.currentTimeMillis());
|
|
||||||
|
var filepathname = String.format(filepath + "%s.json", timestamp.getTime());
|
||||||
var filepathname = String.format(filepath + "%s.json", timestamp.getTime());
|
String sciezka = filepathname;
|
||||||
String sciezka = filepathname;
|
try(FileWriter file = new FileWriter(sciezka)){
|
||||||
try(FileWriter file = new FileWriter(sciezka)){
|
String oldpesel = "";
|
||||||
String oldpesel = "";
|
app:
|
||||||
app:
|
while(n<1) {
|
||||||
while(n<1) {
|
//READ
|
||||||
//READ
|
System.out.println("Podaj nazwę miasta:");
|
||||||
System.out.println("Podaj nazwę miasta:");
|
BufferedReader readercity = new BufferedReader(
|
||||||
BufferedReader readercity = new BufferedReader(
|
new InputStreamReader(System.in));
|
||||||
new InputStreamReader(System.in));
|
String city = readercity.readLine();
|
||||||
String city = readercity.readLine();
|
|
||||||
|
System.out.println("Podaj imię:");
|
||||||
System.out.println("Podaj imię:");
|
BufferedReader readername = new BufferedReader(
|
||||||
BufferedReader readername = new BufferedReader(
|
new InputStreamReader(System.in));
|
||||||
new InputStreamReader(System.in));
|
String name = readername.readLine();
|
||||||
String name = readername.readLine();
|
|
||||||
|
System.out.println("Podaj nazwisko:");
|
||||||
System.out.println("Podaj nazwisko:");
|
BufferedReader readersurnname = new BufferedReader(
|
||||||
BufferedReader readersurnname = new BufferedReader(
|
new InputStreamReader(System.in));
|
||||||
new InputStreamReader(System.in));
|
String surnname = readersurnname.readLine();
|
||||||
String surnname = readersurnname.readLine();
|
|
||||||
|
System.out.println("Podaj PESEL:");
|
||||||
System.out.println("Podaj PESEL:");
|
BufferedReader readerpesel = new BufferedReader(
|
||||||
BufferedReader readerpesel = new BufferedReader(
|
new InputStreamReader(System.in));
|
||||||
new InputStreamReader(System.in));
|
String pesel = readerpesel.readLine();
|
||||||
String pesel = readerpesel.readLine();
|
|
||||||
|
|
||||||
|
|
||||||
|
if(!name.isEmpty() && !surnname.isEmpty() && !city.isEmpty() && !pesel.isEmpty()) {
|
||||||
if(!name.isEmpty() && !surnname.isEmpty() && !city.isEmpty() && !pesel.isEmpty()) {
|
//ADD AND USE PESEL VALID
|
||||||
//ADD AND USE PESEL VALID
|
PeselValid sprawdzpesel = new PeselValid(pesel);
|
||||||
PeselValid sprawdzpesel = new PeselValid(pesel);
|
if (sprawdzpesel.isValid()==true) {
|
||||||
if (sprawdzpesel.isValid()==true) {
|
|
||||||
|
oldpesel = oldpesel + pesel + "; ";
|
||||||
oldpesel = oldpesel + pesel + "; ";
|
|
||||||
|
JSONObject obj = new JSONObject();
|
||||||
JSONObject obj = new JSONObject();
|
if (obj.get("PESEL") == pesel) {
|
||||||
if (obj.get("PESEL") == pesel) {
|
obj.replace("city", city);
|
||||||
obj.replace("city", city);
|
obj.replace("name", name);
|
||||||
obj.replace("name", name);
|
obj.replace("surnname", surnname);
|
||||||
obj.replace("surnname", surnname);
|
obj.replace("PESEL", pesel);
|
||||||
obj.replace("PESEL", pesel);
|
}
|
||||||
}
|
else {
|
||||||
else {
|
|
||||||
|
obj.put("city", city);
|
||||||
obj.put("city", city);
|
obj.put("name", name);
|
||||||
obj.put("name", name);
|
obj.put("surnname", surnname);
|
||||||
obj.put("surnname", surnname);
|
obj.put("PESEL", pesel);
|
||||||
obj.put("PESEL", pesel);
|
|
||||||
|
}
|
||||||
}
|
file.write(obj.toJSONString());
|
||||||
file.write(obj.toJSONString());
|
|
||||||
|
System.out.println(city);
|
||||||
System.out.println(city);
|
System.out.println(name);
|
||||||
System.out.println(name);
|
System.out.println(surnname);
|
||||||
System.out.println(surnname);
|
System.out.println(pesel);
|
||||||
System.out.println(pesel);
|
System.out.println(oldpesel);
|
||||||
System.out.println(oldpesel);
|
|
||||||
|
System.out.println("Dodac kolejne?:[y/n]");
|
||||||
System.out.println("Dodac kolejne?:[y/n]");
|
BufferedReader readeraddornot = new BufferedReader(
|
||||||
BufferedReader readeraddornot = new BufferedReader(
|
new InputStreamReader(System.in));
|
||||||
new InputStreamReader(System.in));
|
String addornot = readeraddornot.readLine();
|
||||||
String addornot = readeraddornot.readLine();
|
switch(addornot) {
|
||||||
switch(addornot) {
|
case "y":
|
||||||
case "y":
|
continue app;
|
||||||
continue app;
|
case "n":
|
||||||
case "n":
|
break app;
|
||||||
break app;
|
default:
|
||||||
default:
|
System.out.println("Błędna komenda!");
|
||||||
System.out.println("Błędna komenda!");
|
break app;
|
||||||
break app;
|
}
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
else
|
{
|
||||||
{
|
System.out.println("Błędny PESEL. Twoje dane nie zostały zapisane!");
|
||||||
System.out.println("Błędny PESEL. Twoje dane nie zostały zapisane!");
|
continue app;
|
||||||
continue app;
|
}
|
||||||
}
|
}
|
||||||
}
|
else {
|
||||||
else {
|
System.out.println("Nie wypełniłeś wszystkich pól! Spróbuj ponownie!");
|
||||||
System.out.println("Nie wypełniłeś wszystkich pól! Spróbuj ponownie!");
|
continue app;
|
||||||
continue app;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
catch (IOException e) {
|
||||||
catch (IOException e) {
|
e.printStackTrace();
|
||||||
e.printStackTrace();
|
}
|
||||||
}
|
|
||||||
|
}
|
||||||
}
|
|
||||||
|
}
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user