add init saga dsc
This commit is contained in:
parent
768e647108
commit
564cf1239f
@ -1,28 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<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>ie.home.besok</groupId>
|
||||
<artifactId>move-clicker</artifactId>
|
||||
<version>1.0</version>
|
||||
<properties>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.10</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.12</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -1,15 +0,0 @@
|
||||
package ie.home.besok.stirrings;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
|
||||
public class Application {
|
||||
public static void main(String[] args) throws IOException {
|
||||
FileStorage storage = new FileStorage();
|
||||
|
||||
EventQueue.invokeLater(() -> {
|
||||
Gui gui = new Gui(storage);
|
||||
gui.setVisible(true);
|
||||
});
|
||||
}
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
package ie.home.besok.stirrings;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class Counter {
|
||||
public Map<LocalDate,Long> count(List<String> dates){
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
package ie.home.besok.stirrings;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.nio.file.StandardOpenOption;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
public class FileStorage {
|
||||
|
||||
private Path file;
|
||||
|
||||
public FileStorage() throws IOException {
|
||||
this.file = Paths.get("data.log");
|
||||
if(!Files.exists(file)){
|
||||
Files.createFile(file);
|
||||
}
|
||||
}
|
||||
|
||||
public void plus() {
|
||||
String line = LocalDateTime.now().toString()+System.lineSeparator();
|
||||
try {
|
||||
Files.write(file, line.getBytes(), StandardOpenOption.APPEND);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public List<String> get() throws IOException {
|
||||
return Files.readAllLines(file);
|
||||
}
|
||||
|
||||
}
|
@ -1,73 +0,0 @@
|
||||
package ie.home.besok.stirrings;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
|
||||
public class Gui extends JFrame {
|
||||
|
||||
private FileStorage storage;
|
||||
|
||||
public Gui(FileStorage storage) {
|
||||
this.storage = storage;
|
||||
try {
|
||||
createUI(storage);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void createUI(FileStorage storage) throws IOException {
|
||||
setTitle("Stirring counter");
|
||||
setSize(300, 300);
|
||||
setLocationRelativeTo(null);
|
||||
|
||||
|
||||
JButton button = createButton(storage);
|
||||
JButton graphick = new JButton();
|
||||
graphick.setIcon(getIcon("3.jpg"));
|
||||
|
||||
|
||||
Container pane = getContentPane();
|
||||
GroupLayout gl = new GroupLayout(pane);
|
||||
pane.setLayout(gl);
|
||||
|
||||
gl.setAutoCreateContainerGaps(true);
|
||||
|
||||
gl.setHorizontalGroup(
|
||||
gl.createSequentialGroup().addComponent(button).addComponent(graphick)
|
||||
);
|
||||
|
||||
gl.setVerticalGroup(gl.createSequentialGroup().addComponent(button).addComponent(graphick));
|
||||
|
||||
|
||||
button.addActionListener((event) -> {
|
||||
storage.plus();
|
||||
try {
|
||||
JOptionPane.showMessageDialog(null,"","",JOptionPane.INFORMATION_MESSAGE, getIcon("2.jpg"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
|
||||
setDefaultCloseOperation(EXIT_ON_CLOSE);
|
||||
}
|
||||
|
||||
private JButton createButton(FileStorage storage) throws IOException {
|
||||
ImageIcon babyIcon = getIcon("1.png");
|
||||
|
||||
JButton button = new JButton();
|
||||
|
||||
button.setIcon(babyIcon);
|
||||
return button;
|
||||
}
|
||||
|
||||
private ImageIcon getIcon(String name) throws IOException {
|
||||
URL file = this.getClass().getClassLoader().getResource(name);
|
||||
return new ImageIcon(ImageIO.read(file));
|
||||
}
|
||||
|
||||
|
||||
}
|
Binary file not shown.
Before Width: | Height: | Size: 4.3 KiB |
Binary file not shown.
Before Width: | Height: | Size: 3.5 KiB |
Binary file not shown.
Before Width: | Height: | Size: 2.8 KiB |
@ -1,25 +0,0 @@
|
||||
package ie.home.besok.stirrings;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class FileStorageTest {
|
||||
|
||||
@Test
|
||||
public void fsTest() throws IOException {
|
||||
FileStorage fs = new FileStorage();
|
||||
List<String> arrs = fs.get();
|
||||
int oldSize = arrs.size();
|
||||
fs.plus();
|
||||
fs.plus();
|
||||
fs.plus();
|
||||
fs.plus();
|
||||
arrs = fs.get();
|
||||
int newSize = arrs.size();
|
||||
assertEquals(4, newSize - oldSize);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user