This repository has been archived by the owner on Oct 25, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
166 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,3 +12,4 @@ extra/ | |
riscv-tools/ | ||
*.elf | ||
*.o | ||
**/.idea |
9 changes: 9 additions & 0 deletions
9
2019_ProgrammazioneAdOggetti/unimore/src/eu/steffo/unimore/Main.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package eu.steffo.unimore; | ||
|
||
public class Main { | ||
|
||
//Metodi ``public static void`` con ``String[] args`` possono essere considerati main | ||
public static void main(String[] args) { | ||
|
||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
2019_ProgrammazioneAdOggetti/unimore/src/eu/steffo/unimore/esempi/Esempio.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
//Questo è il nome del package | ||
package eu.steffo.unimore.esempi; | ||
|
||
//Qui dico a IntelliJ di stare zitto | ||
@SuppressWarnings("All") | ||
//Qui dichiaro una classe visibile dall'esterno del package e che quindi può essere usata in altri programmi | ||
public class Esempio { | ||
//Qui aggiungo attributi alla classe | ||
|
||
//Questo attributo è pubblico e può essere letto / modificato dall'esterno della classe | ||
public int numeroDellEsempio; | ||
//Questo attributo è privato e può essere letto / modificato SOLO da questa classe | ||
private int unNumeroACaso; | ||
//Questo attributo è protetto e può essere letto / modificato SOLO da questa classe o classi che estendono questa | ||
protected int volteCheHoFattoGet; | ||
//Questo attributo è amichevole ^_^ e può essere letto / modificato SOLO da classi in questo package | ||
//E' quello che succede se non si specifica un livello di protezione | ||
/*friendly*/ int amicizia; | ||
|
||
//Questo attributo è statico e condiviso tra tutte le istanze della classe, ed è inizializzato a 0 | ||
private static int numeroTotaleDiEsempi = 0; | ||
|
||
//Questo attributo non può essere modificato fuori dal costruttore | ||
private final int sembraUnBossFinale; | ||
|
||
//Questo attributo è una costante | ||
private static final int PI = 3; | ||
|
||
//Questo è un metodo pubblico ed è il collante tra gli attributi privati e gli altri programmi | ||
//In questo caso, posso vedere il valore di unNumeroACaso ma non modificarlo | ||
public int getUnNumeroACaso() { | ||
volteCheHoFattoGet += 1; | ||
return unNumeroACaso; | ||
} | ||
|
||
//Overload: se definisco più funzioni con lo stesso nome ma argomenti diversi, Java mi userà automaticamente quella | ||
//corretta | ||
public int getUnNumeroACaso(int contaComeVolte) { | ||
volteCheHoFattoGet += contaComeVolte; | ||
return unNumeroACaso; | ||
} | ||
|
||
//Questo è il costruttore, è una funzione speciale che viene chiamato quando la classe sta per essere creata | ||
public Esempio(int a, int sembraUnBossFinale) { | ||
numeroDellEsempio = a; | ||
unNumeroACaso = -a; | ||
volteCheHoFattoGet = 0; | ||
numeroTotaleDiEsempi += 1; | ||
|
||
//Se un parametro copre il nome di un attributo, posso comunque accedere all'attributo con la parola chiave this | ||
this.sembraUnBossFinale = sembraUnBossFinale; | ||
} | ||
|
||
//Posso fare l'overload anche dei costruttori | ||
public Esempio() { | ||
numeroDellEsempio = 0; | ||
unNumeroACaso = 0; | ||
volteCheHoFattoGet = 0; | ||
numeroTotaleDiEsempi += 1; | ||
sembraUnBossFinale = 123; | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
2019_ProgrammazioneAdOggetti/unimore/src/eu/steffo/unimore/esempi/EsempioDue.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package eu.steffo.unimore.esempi; | ||
|
||
//Qui creo una nuova classe che eredita da Esempio | ||
//Ha tutti gli attributi e metodi di Esempio, e in più ce ne posso aggiungere altri | ||
public class EsempioDue extends Esempio { | ||
//Definisco un nuovo attributo | ||
private int unNuovoInizio; | ||
|
||
//Definisco un nuovo metodo | ||
public int getUnNuovoInizio() { | ||
return unNuovoInizio; | ||
} | ||
|
||
//Override: posso modificare metodi della classe superiore, cambiandone il comportamento | ||
@Override | ||
public int getUnNumeroACaso() { | ||
//Faccio qualcosa prima dell'esecuzione della funzione | ||
volteCheHoFattoGet += 1; | ||
//Se sono coperti da qualcosa di questa classe, posso accedere ai metodi della classe superiore usando super | ||
int result = super.getUnNumeroACaso(); | ||
//Faccio qualcosa dopo l'esecuzione della funzione | ||
volteCheHoFattoGet += 1; | ||
|
||
return result; | ||
} | ||
|
||
//I costruttori non vengono ereditati; devo farne comunque uno nuovo | ||
public EsempioDue() { | ||
//Posso però invocarli con super | ||
super(); | ||
//Aggiungo qualcosa | ||
unNuovoInizio = 321; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<module type="JAVA_MODULE" version="4"> | ||
<component name="NewModuleRootManager" inherit-compiler-output="true"> | ||
<exclude-output /> | ||
<content url="file://$MODULE_DIR$"> | ||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> | ||
</content> | ||
<orderEntry type="inheritedJdk" /> | ||
<orderEntry type="sourceFolder" forTests="false" /> | ||
</component> | ||
</module> | ||
|
28 changes: 28 additions & 0 deletions
28
2019_StatisticaEProbabilità/07_IlParadossoDeiCompleanni.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Il Paradosso dei Compleanni | ||
|
||
> Un docente è in aula con `n` studenti. | ||
> | ||
> Supponendo per semplicità che i compleanni siano distribuiti uniformemente nel corso dell'anno e che nessuno dei presenti sia nato il 29 febbraio, quanto valuteremo, in funzione di `n`, la probabilità che vi sia in aula uno studente con il compleanno nello stesso giorno del docente? | ||
> | ||
> La probabilità che vi siano in aula due persone con il compleanno lo stesso giorno? | ||
> | ||
> Quanto valgono queste probabilità per `n` = 50? | ||
> | ||
> Quanto deve essere grande `n` affinchè ciascuna di queste probabilità risulti maggiore del 50%? | ||
```latex | ||
\Omega = \{(\omega_0, \omega_1, \dots, \omega_n | \omega_i \in {1, 2, \dots, 365}, i = 0, 1, \dots, n)\} | ||
\corsivo{F} = \corsivo{p)(\Omega) | ||
|\Omega| = 365^{n+1} | ||
E = almeno\ una\ coincidenza\ con\ docente | ||
F = almeno\ due\ compleanni\ uguali | ||
\mathbb{P}(E) \leq \mathbb{P}(F) | ||
\mathbb{P}(E) = 1 - \mathbb{P}(¬E) = 1 - \frac{365*364*364*\dots*364}{365^{n+1}} = 1 - \frac{364}{365}^n | ||
\mathbb{P}(F) = 1 - \mathbb{P}(¬F) = 1 - \frac{364*363*362*361*\dots*(365-n)}{365^{n+1}} = 1 - \PRODUCT_{i=0}^n \frac{365-i}{365} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Spazi | ||
|
||
## Spazi combinatori | ||
|
||
Sono _spazi combinatori_: | ||
|
||
- disposizioni | ||
- disposizioni con ripetizione | ||
- combinazioni | ||
- permutazioni | ||
|
||
### Disposizioni | ||
|
||
### Disposizioni con ripetizione | ||
|
||
### Combinazioni | ||
|
||
I casi totali sono `n!`, mentre i casi favoreboli sono `` | ||
|
||
### Permutazioni |