From d1df819173810519f10ab1a2cca2d240fd47df31 Mon Sep 17 00:00:00 2001
From: Sanna Tolppanen <sktolp@utu.fi>
Date: Sun, 7 Jul 2024 20:48:01 +0300
Subject: [PATCH] koko projekti

---
 .gitignore                               | 38 ++++++++++++++++
 .idea/.gitignore                         |  3 ++
 .idea/encodings.xml                      |  7 +++
 .idea/misc.xml                           | 15 +++++++
 .idea/vcs.xml                            |  6 +++
 pom.xml                                  | 35 +++++++++++++++
 src/main/java/Kirjahylly.java            | 57 ++++++++++++++++++++++++
 src/main/java/fi/utu/omatunnus/Main.java | 17 +++++++
 8 files changed, 178 insertions(+)
 create mode 100644 .gitignore
 create mode 100644 .idea/.gitignore
 create mode 100644 .idea/encodings.xml
 create mode 100644 .idea/misc.xml
 create mode 100644 .idea/vcs.xml
 create mode 100644 pom.xml
 create mode 100644 src/main/java/Kirjahylly.java
 create mode 100644 src/main/java/fi/utu/omatunnus/Main.java

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..5ff6309
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,38 @@
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**/target/
+!**/src/test/**/target/
+
+### IntelliJ IDEA ###
+.idea/modules.xml
+.idea/jarRepositories.xml
+.idea/compiler.xml
+.idea/libraries/
+*.iws
+*.iml
+*.ipr
+
+### Eclipse ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+!**/src/main/**/build/
+!**/src/test/**/build/
+
+### VS Code ###
+.vscode/
+
+### Mac OS ###
+.DS_Store
\ No newline at end of file
diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..26d3352
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,3 @@
+# Default ignored files
+/shelf/
+/workspace.xml
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
new file mode 100644
index 0000000..aa00ffa
--- /dev/null
+++ b/.idea/encodings.xml
@@ -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>
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..970f095
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,15 @@
+<?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>
+    <option name="workspaceImportForciblyTurnedOn" value="true" />
+  </component>
+  <component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="temurin-21" project-jdk-type="JavaSDK">
+    <output url="file://$PROJECT_DIR$/out" />
+  </component>
+</project>
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -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>
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..0f1acf8
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,35 @@
+<?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>fi.utu.omatunnus</groupId>
+    <artifactId>Viikko4-1</artifactId>
+    <version>1.0-SNAPSHOT</version>
+
+    <properties>
+        <maven.compiler.source>21</maven.compiler.source>
+        <maven.compiler.target>21</maven.compiler.target>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.junit.jupiter</groupId>
+            <artifactId>junit-jupiter</artifactId>
+            <version>5.9.2</version>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <version>2.22.2</version>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>
\ No newline at end of file
diff --git a/src/main/java/Kirjahylly.java b/src/main/java/Kirjahylly.java
new file mode 100644
index 0000000..ffc5dfe
--- /dev/null
+++ b/src/main/java/Kirjahylly.java
@@ -0,0 +1,57 @@
+import java.util.ArrayList;
+
+/**
+ * Luokka mallintaa yksinkertaista kirjahyllyä
+ */
+public class Kirjahylly {
+    private ArrayList<String> kirjat;
+
+    private int kirjojaHyllyssa = 0;
+
+    public Kirjahylly() {
+        kirjat = new ArrayList<>();
+        kirjojaHyllyssa = 0;
+    }
+
+    /**
+     * Lisää yhden kirjan hyllyyn
+     * @param kirja lisättävä kirja
+     */
+    public void lisaaKirja(String kirja) {
+        kirjat.add(kirja);
+        kirjojaHyllyssa = kirjojaHyllyssa + 1;
+
+    }
+
+    /**
+     * Palauttaa kirjahyllyyn viimeksi lisätyn kirjan
+     * @return viimeksi lisätyn kirjan
+     */
+    public String viimeksiLisatty() {
+        return kirjat.get(kirjat.size() - 1);
+    }
+
+    /**
+     * Palauttaa tiedon siitä onko annettu kirja hyllyssä
+     * @param kirja kirja, jota etsitään
+     * @return <code>true</code>, jos kirjan on hyllyssä, muuten <code>false</code>
+     */
+    public boolean onkoKirjaHyllyssa(String kirja) {
+        for (String k : kirjat) {
+            if (k == kirja) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    /**
+     * Palautta kirjahyllyssä olevien kirjojen määrän
+     * @return kirjojen määrän hyllyssä
+     */
+    public int getKirjojaHyllyssa() {
+
+        return kirjojaHyllyssa;
+    }
+}
+
diff --git a/src/main/java/fi/utu/omatunnus/Main.java b/src/main/java/fi/utu/omatunnus/Main.java
new file mode 100644
index 0000000..7d69eb7
--- /dev/null
+++ b/src/main/java/fi/utu/omatunnus/Main.java
@@ -0,0 +1,17 @@
+package fi.utu.omatunnus;
+
+//TIP To <b>Run</b> code, press <shortcut actionId="Run"/> or
+// click the <icon src="AllIcons.Actions.Execute"/> icon in the gutter.
+public class Main {
+    public static void main(String[] args) {
+        //TIP Press <shortcut actionId="ShowIntentionActions"/> with your caret at the highlighted text
+        // to see how IntelliJ IDEA suggests fixing it.
+        System.out.printf("Hello and welcome!");
+
+        for (int i = 1; i <= 5; i++) {
+            //TIP Press <shortcut actionId="Debug"/> to start debugging your code. We have set one <icon src="AllIcons.Debugger.Db_set_breakpoint"/> breakpoint
+            // for you, but you can always add more by pressing <shortcut actionId="ToggleLineBreakpoint"/>.
+            System.out.println("i = " + i);
+        }
+    }
+}
\ No newline at end of file
-- 
GitLab