Aggiunta Videoteca
This commit is contained in:
parent
e850031d40
commit
f7272926a2
3
Videoteca/.idea/.gitignore
generated
vendored
Normal file
3
Videoteca/.idea/.gitignore
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
6
Videoteca/.idea/misc.xml
generated
Normal file
6
Videoteca/.idea/misc.xml
generated
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_19" default="true" project-jdk-name="19" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
8
Videoteca/.idea/modules.xml
generated
Normal file
8
Videoteca/.idea/modules.xml
generated
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/Videoteca.iml" filepath="$PROJECT_DIR$/Videoteca.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
124
Videoteca/.idea/uiDesigner.xml
generated
Normal file
124
Videoteca/.idea/uiDesigner.xml
generated
Normal file
@ -0,0 +1,124 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Palette2">
|
||||
<group name="Swing">
|
||||
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
|
||||
</item>
|
||||
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.svg" removable="false" auto-create-binding="false" can-attach-label="true">
|
||||
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
|
||||
<initial-values>
|
||||
<property name="text" value="Button" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="RadioButton" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="CheckBox" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="Label" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
|
||||
<preferred-size width="-1" height="20" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
|
||||
</item>
|
||||
</group>
|
||||
</component>
|
||||
</project>
|
6
Videoteca/.idea/vcs.xml
generated
Normal file
6
Videoteca/.idea/vcs.xml
generated
Normal file
@ -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>
|
12
Videoteca/Istruzioni.md
Normal file
12
Videoteca/Istruzioni.md
Normal file
@ -0,0 +1,12 @@
|
||||
Scrivere una classe Videogioco che rappresenti le seguenti informazioni relative ad un videogioco: titolo, casa produttrice, piattaforma e prezzo, e che contenga il costruttore parametrizzato ed i metodi getTitolo, getCasaProduttrice, getPiattaforma e getPrezzo che restituiscono rispettivamente il titolo, la casa produttrice, la piattaforma e il prezzo del videogioco.
|
||||
|
||||
Scrivere poi una classe Videoteca, che rappresenti un insieme di videogiochi tramite un array di tipo Videogioco, e che contenga il costruttore parametrizzato, un metodo addVideogioco(), che aggiunge un videogioco alla Videoteca, un metodo trova(), che accetta in ingresso una casa produttrice c e un numero reale k e restituisce il numero di videogiochi contenuti nella videoteca prodotti dalla casa produttrice c e con prezzo superiore a k.
|
||||
|
||||
Aggiungere alla classe Videoteca un metodo che accetti una casa produttrice c e restituisca i titoli di tutti i videogiochi prodotti dalla casa produttrice c.
|
||||
|
||||
Scrivere la classe di collaudo che:
|
||||
• istanzia una Videoteca
|
||||
• Istanzia qualche videogioco che viene aggiunto alla Videoteca
|
||||
• prova i diversi metodi, uno alla volta, nell’ordine di realizzazione.
|
||||
|
||||
NB: aggiungere alle classi anche i metodi necessari perché nella classe tester possano essere visualizzati i Videogiochi contenuti nella Videoteca.
|
11
Videoteca/Videoteca.iml
Normal file
11
Videoteca/Videoteca.iml
Normal file
@ -0,0 +1,11 @@
|
||||
<?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>
|
11
Videoteca/src/Tester.java
Normal file
11
Videoteca/src/Tester.java
Normal file
@ -0,0 +1,11 @@
|
||||
public class Tester {
|
||||
public static void main(String[] args) {
|
||||
Videoteca myVideoteca = new Videoteca();
|
||||
|
||||
myVideoteca.addVideogioco(new Videogioco("Test1", "Nintendo", "Switch", 5));
|
||||
myVideoteca.addVideogioco(new Videogioco("Test2", "Microsoft", "Switch", 100));
|
||||
|
||||
System.out.println(myVideoteca.trova("Nintendo", 1));
|
||||
System.out.println(myVideoteca.trova("Nintendo").toString());
|
||||
}
|
||||
}
|
34
Videoteca/src/Videogioco.java
Normal file
34
Videoteca/src/Videogioco.java
Normal file
@ -0,0 +1,34 @@
|
||||
public class Videogioco {
|
||||
private final String titolo;
|
||||
private final String casaProduttrice;
|
||||
private final String piattaforma;
|
||||
private final double prezzo;
|
||||
|
||||
public Videogioco(String titolo, String casaProduttrice, String piattaforma, double prezzo) {
|
||||
this.titolo = titolo;
|
||||
this.casaProduttrice = casaProduttrice;
|
||||
this.piattaforma = piattaforma;
|
||||
this.prezzo = prezzo;
|
||||
}
|
||||
|
||||
public String getTitolo() {
|
||||
return titolo;
|
||||
}
|
||||
|
||||
public String getCasaProduttrice() {
|
||||
return casaProduttrice;
|
||||
}
|
||||
|
||||
public String getPiattaforma() {
|
||||
return piattaforma;
|
||||
}
|
||||
|
||||
public double getPrezzo() {
|
||||
return prezzo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return titolo + " di " + casaProduttrice + " per " + piattaforma + ", " + prezzo + "€";
|
||||
}
|
||||
}
|
34
Videoteca/src/Videoteca.java
Normal file
34
Videoteca/src/Videoteca.java
Normal file
@ -0,0 +1,34 @@
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Videoteca {
|
||||
private ArrayList<Videogioco> giochi = new ArrayList<>();
|
||||
|
||||
public Videoteca() {}
|
||||
|
||||
public void addVideogioco(Videogioco videogioco) {
|
||||
giochi.add(videogioco);
|
||||
}
|
||||
|
||||
public int trova(String c, int k) {
|
||||
int validi = 0;
|
||||
for(Videogioco gioco : giochi) {
|
||||
if(gioco.getCasaProduttrice().equals(c) && gioco.getPrezzo() > k) {
|
||||
validi++;
|
||||
}
|
||||
}
|
||||
|
||||
return validi;
|
||||
}
|
||||
|
||||
public ArrayList<Videogioco> trova(String c) {
|
||||
ArrayList<Videogioco> validi = new ArrayList<>();
|
||||
|
||||
for(Videogioco gioco : giochi) {
|
||||
if(gioco.getCasaProduttrice().equals(c)) {
|
||||
validi.add(gioco);
|
||||
}
|
||||
}
|
||||
|
||||
return validi;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user