1 files modified
5 files renamed
11 files added
245 ■■■■■ changed files
.devcontainer/Dockerfile 18 ●●●●● patch | view | raw | blame | history
.devcontainer/devcontainer.json 20 ●●●●● patch | view | raw | blame | history
.devcontainer/docker-compose.yml 11 ●●●●● patch | view | raw | blame | history
.gitignore 7 ●●●●● patch | view | raw | blame | history
.vscode/settings.json 29 ●●●●● patch | view | raw | blame | history
pom.xml 45 ●●●●● patch | view | raw | blame | history
src/main/java/DivisorPattern.java 16 ●●●●● patch | view | raw | blame | history
src/main/java/Kary.java patch | view | raw | blame | history
src/main/java/Main.java 5 ●●●●● patch | view | raw | blame | history
src/main/java/NumeroPrimo.java 36 ●●●●● patch | view | raw | blame | history
src/main/java/PowerOfTwo.java 15 ●●●●● patch | view | raw | blame | history
src/main/java/RelativamentePrimo.java patch | view | raw | blame | history
src/main/java/SommaDiDueCubi.java patch | view | raw | blame | history
src/main/java/SommaDiDueCubiHash.java patch | view | raw | blame | history
src/main/java/SommaDiDueCubiLimitato.java patch | view | raw | blame | history
src/main/java/TenHello.java 13 ●●●●● patch | view | raw | blame | history
src/test/java/NumeroPrimoTest.java 30 ●●●●● patch | view | raw | blame | history
.devcontainer/Dockerfile
New file
@@ -0,0 +1,18 @@
FROM openjdk:25-ea-18-slim
# Install tools (esempio: Maven)
RUN apt-get update && \
    apt-get install -y maven git curl unzip && \
    rm -rf /var/lib/apt/lists/*
# Crea utente vscode (richiesto per VS Code Dev Container)
RUN useradd -ms /bin/bash vscode && echo "vscode ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
# Imposta la directory di lavoro
WORKDIR /workspace
# Imposta utente vscode
USER vscode
ENV JAVA_HOME=/usr/local/openjdk-25
ENV PATH=$JAVA_HOME/bin:$PATH
.devcontainer/devcontainer.json
New file
@@ -0,0 +1,20 @@
{
  "name": "Java Dev Container",
  "dockerComposeFile": "docker-compose.yml",
  "service": "java-dev",
  "workspaceFolder": "/workspace",
  "customizations": {
    "vscode": {
      "settings": {
        "terminal.integrated.defaultProfile.linux": "bash"
      },
      "extensions": [
        "vscjava.vscode-java-pack",     // Java Extension Pack
        "pivotal.vscode-spring-boot",   // Spring support (opzionale)
        "test-editor.test-editor",      // Supporto ai test (opzionale)
        "redhat.java",                  // Supporto al linguaggio Java
        "dotjoshjohnson.xml"            // XML Tools
      ]
    }
  }
}
.devcontainer/docker-compose.yml
New file
@@ -0,0 +1,11 @@
services:
  java-dev:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: java-dev
    volumes:
      - ..:/workspace:cached
    tty: true
    command: sleep infinity
.gitignore
@@ -23,11 +23,10 @@
/nbdist/
/.nb-gradle/
### VS Code ###
.vscode/
### intellij ###
.idea/
### Mac OS ###
.DS_Store
.DS_Store
target/
.vscode/settings.json
New file
@@ -0,0 +1,29 @@
{
  // ✅ Salvataggio automatico dopo una pausa di 1 secondo
  "files.autoSave": "afterDelay",
  "files.autoSaveDelay": 1000,
  // ✅ Mostra tutte le cartelle espanse (disattiva la "compattazione" nel file explorer)
  "explorer.compactFolders": false,
  // (Facoltativo) ✅ Imposta il linguaggio di default per nuovi file senza estensione
  "files.defaultLanguage": "java",
  "[java]": {
    "editor.defaultFormatter": "redhat.java",
    "editor.formatOnSave": true
  },
  // ✅ Abilita linting e suggerimenti Java
  "java.errors.incompleteClasspath.severity": "warning",
  "java.configuration.checkProjectSettingsExclusions": false,
  "java.configuration.updateBuildConfiguration": "automatic",
  "java.import.gradle.enabled": false,
  "java.import.maven.enabled": true,
  // (Facoltativo) ✅ Rendi visibili anche i file nascosti (come .gitignore, ecc.)
  "files.exclude": {
    "**/.git": false,
    "**/.DS_Store": true
  }
}
pom.xml
New file
@@ -0,0 +1,45 @@
<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>com.example</groupId>
    <artifactId>java-dev-container-project</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>
    <properties>
        <maven.compiler.source>25</maven.compiler.source>
        <maven.compiler.target>25</maven.compiler.target>
    </properties>
    <dependencies>
        <!-- Add your project dependencies here -->
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter</artifactId>
            <version>5.10.0</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <source>25</source>
                    <target>25</target>
                </configuration>
            </plugin>
            <!-- Plugin per eseguire i test -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>3.2.5</version>
            </plugin>
        </plugins>
    </build>
</project>
src/main/java/DivisorPattern.java
New file
@@ -0,0 +1,16 @@
public class DivisorPattern {
    public static void main(String[] args) {
        int limite = Integer.parseInt(args[0]);
        for (int i = 1; i <= limite; i++) {
            for (int j = 1; j <= i; j++) {
                if (i % j == 0) {
                    System.out.print("* ");
                } else {
                    System.out.print("  ");
                }
            }
            System.out.println();
        }
    }
}
src/main/java/Kary.java
src/main/java/Main.java
New file
@@ -0,0 +1,5 @@
public class Main {
    public static void main(String[] args) {
        System.out.println("Hello, World!");
    }
}
src/main/java/NumeroPrimo.java
New file
@@ -0,0 +1,36 @@
public class NumeroPrimo {
    public boolean isPrimo(int numero) {
        if (numero <= 1) {
            return false;
        }
        if (numero % 2 == 0) {
            return false;
        }
        for (int i = 3; i <= Math.sqrt(numero); i += 2) {
            if (numero % i == 0) {
                return false;
            }
        }
        return true;
    }
    public static void main(String[] args) {
        NumeroPrimo np = new NumeroPrimo();
        int limite = Integer.parseInt(args[0]);
        long startTime = System.nanoTime();
        int conta = 1;
        for (int i = 3; i <= limite; i += 2) {
            if (np.isPrimo(i)) {
                System.out.println(conta + " " + i);
                conta++;
            }
        }
        long endTime = System.nanoTime(); // ⏱️ Fine
        long duration = endTime - startTime; // in nanosecondi
        System.out.println("Tempo di esecuzione: " + (duration / 1_000_000) + " ms");
    }
}
src/main/java/PowerOfTwo.java
New file
@@ -0,0 +1,15 @@
public class PowerOfTwo {
    public static void main(String[] args) {
        int limite = Integer.parseInt(args[0]);
        int conta = 1;
        for (int i = 1; i <= limite; i++) {
            int potenza = i * i;
            if (potenza <= limite) {
                System.out.println(conta + " " + potenza);
                conta++;
            }
        }
    }
}
src/main/java/RelativamentePrimo.java
src/main/java/SommaDiDueCubi.java
src/main/java/SommaDiDueCubiHash.java
src/main/java/SommaDiDueCubiLimitato.java
src/main/java/TenHello.java
New file
@@ -0,0 +1,13 @@
public class TenHello {
    public static void main(String[] args) {
        System.out.println("Hello, World! " + "1st");
        System.out.println("Hello, World! " + "2sd");
        System.out.println("Hello, World! " + "3rd");
        for (int i = 4; i <= 10; i++) {
            System.out.println("Hello, World! " + i + "th");
        }
    }
}
src/test/java/NumeroPrimoTest.java
New file
@@ -0,0 +1,30 @@
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
public class NumeroPrimoTest {
    @Test
    void testPrimo1() {
        NumeroPrimo primo = new NumeroPrimo();
        assertEquals(false, primo.isPrimo(1));
    }
    @Test
    void testPrimoNegativo() {
        NumeroPrimo primo = new NumeroPrimo();
        assertEquals(false, primo.isPrimo(-101));
    }
    @Test
    void testSomma() {
        NumeroPrimo primo = new NumeroPrimo();
        assertEquals(true, primo.isPrimo(3));
    }
    @Test
    void testSommaNegativi() {
        NumeroPrimo primo = new NumeroPrimo();
        assertEquals(false, primo.isPrimo(4));
    }
}