Skip to content
Snippets Groups Projects
Commit d1df8191 authored by Sanna Tolppanen's avatar Sanna Tolppanen
Browse files

koko projekti

parent 1b6707c4
No related branches found
No related tags found
No related merge requests found
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
# Default ignored files
/shelf/
/workspace.xml
<?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
<?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
<?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
pom.xml 0 → 100644
<?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
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;
}
}
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment