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