| 
 | |||||||
| 
 | 
|  | 
|  | 
|  | Strumenti | 
|  29-12-2005, 15:21 | #1 | 
| Senior Member Iscritto dal: May 2004 Città: Padova 
					Messaggi: 2221
				 | 
				
				operator && cannot be applied to int, int
			 
		Devo fare un altro programma per scuola.. non ho capito una cosa però.. Io sto lavorando con la GUI .. quindi sto creando un'interfaccia grafica.. vi posto il codice con l'errore.. //Dna import javax.swing.*; import java.awt.*; import java.awt.event.*; public class Credito extends JFrame implements ActionListener { //creo 5 pannelli JPanel p1 = new JPanel(); JPanel p2 = new JPanel(); JPanel p3 = new JPanel(); JPanel p4 = new JPanel(); JPanel p5 = new JPanel(); //creo 3 JTextField JTextField media = new JTextField(10); JTextField debiti = new JTextField(10); JTextField crediti = new JTextField(10); //creo 3 pulsanti JButton calcola = new JButton("Calcola credito"); JButton annulla = new JButton("Annulla"); JButton cambiaColore = new JButton("Cambio colore testo label"); //crea una combobox JComboBox sceltaColor = new JComboBox(); //Creo 4 etichette non modificabili JLabel l1 = new JLabel("Media voti"); JLabel l2 = new JLabel("Numero debiti"); JLabel l3 = new JLabel("Punti di credito"); JLabel l4 = new JLabel("Colore testo Label"); public Credito(String titolo) { super(titolo); setBounds(50,50,500,400); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); getContentPane().setBackground(Color.WHITE); p1.setBackground(Color.BLACK); p2.setBackground(Color.BLACK); p3.setBackground(Color.BLACK); p4.setBackground(Color.BLACK); p5.setBackground(Color.BLACK); calcola.setBackground(Color.WHITE); calcola.setForeground(Color.BLACK); annulla.setBackground(Color.WHITE); annulla.setForeground(Color.BLACK); cambiaColore.setBackground(Color.WHITE); cambiaColore.setForeground(Color.BLACK); l1.setForeground(Color.GREEN); l2.setForeground(Color.GREEN); l3.setForeground(Color.GREEN); l4.setForeground(Color.GREEN); sceltaColor.addItem("Rosso"); sceltaColor.addItem("Blu"); sceltaColor.addItem("Giallo"); sceltaColor.addItem("Verde"); getContentPane().setLayout(new GridLayout(5,1)); p1.add(l1); p1.add(media); p2.add(l2); p2.add(debiti); p3.add(calcola); p3.add(annulla); p4.add(l3); p4.add(crediti); p5.add(l4); p5.add(sceltaColor); p5.add(cambiaColore); getContentPane().add(p1); getContentPane().add(p2); getContentPane().add(p3); getContentPane().add(p4); getContentPane().add(p5); calcola.addActionListener(this); annulla.addActionListener(this); cambiaColore.addActionListener(this); setVisible(true); } public void actionPerformed(ActionEvent e) { JButton source =(JButton) e.getSource(); int A,B; if(source == annulla) { media.setText(""); debiti.setText(""); crediti.setText(""); } if(source == calcola) { if(A<6) { crediti.setText("0"); } if((A=6)&&(B=0)) { crediti.setText("2"); } } } public static void main(String args[]) { Credito c = new Credito("Calcola Credito"); } } devo: calcolare i punti di credito in base alla tabella Media voti M<6 punti credito 0 M=6 2-3 punti 6<M<=7 3-4 punti 7<M<=8 4-5 punti M>8 5-6 pnt In più se c'è un debito devo prendere il valore piu basso della fascia .. tipo se ho la media >8 e ho un debito prendo 5 punti.. e non 6.. Ok il mio problema sta nel fare gli If... non mi lascia fare Codice: if((A=6)&&(B=0)) 
				__________________ http://www.flickr.com/photos/dnamat/ | 
| ![DnA[TF] è offline](images_hwu/statusicon/user_offline.gif)  |   | 
|  29-12-2005, 15:59 | #2 | |
| Senior Member Iscritto dal: Nov 2005 Città: TO 
					Messaggi: 5206
				 | Quote: 
 Soluzione: Codice: if((A==6)&&(B==0)) 
				__________________ Andrea, SCJP 5 (91%) - SCWCD 5 (94%) | |
|   |   | 
|  29-12-2005, 16:09 | #3 | |
| Senior Member Iscritto dal: May 2004 Città: Padova 
					Messaggi: 2221
				 | Quote: 
 Grazie mille!! se ho altri dubbi io cerco di postare qui!! Ho visto che mi aiutate un sacco!! Ancora mille grazie! PS: che siete ingegneri informatici per caso?   
				__________________ http://www.flickr.com/photos/dnamat/ | |
| ![DnA[TF] è offline](images_hwu/statusicon/user_offline.gif)  |   | 
|  29-12-2005, 16:42 | #4 | |
| Senior Member Iscritto dal: Nov 2005 Città: TO 
					Messaggi: 5206
				 | Quote: 
 Io non sono ingegnere e non penso di aver qualcosa in meno di loro ...   
				__________________ Andrea, SCJP 5 (91%) - SCWCD 5 (94%) | |
|   |   | 
|  29-12-2005, 17:53 | #5 | |
| Senior Member Iscritto dal: May 2005 Città: Roma 
					Messaggi: 7938
				 | Quote: 
             Certo, magari ho qualche conoscenza teorica in più, ma come si dice dalle mie parti, e per l'informatica è legge, secondo me, A FATIGA E' MEGLIO DA GRAMMATICA!!!! 
				__________________ My gaming placement | |
|   |   | 
|  29-12-2005, 20:53 | #6 | |
| Senior Member Iscritto dal: Nov 2005 Città: TO 
					Messaggi: 5206
				 | Quote: 
  Guarda che ... io comunque (ci tengo a precisarlo) non volevo offendere nessun ingegnere o insinuare che un ingegnere è inferiore e/o meno bravo di me!!!   
				__________________ Andrea, SCJP 5 (91%) - SCWCD 5 (94%) | |
|   |   | 
|  30-12-2005, 00:10 | #7 | |
| Senior Member Iscritto dal: May 2005 Città: Roma 
					Messaggi: 7938
				 | Quote: 
 Ho appena finito di leggere MASTER OF DOOM, è quel libro non ha fatto altro che confermare la mia teoria. Comunque è normale che un ing. abbia delle conoscenze teoriche che un informatico semplice non ha, altrimenti che mi sto laureando a fare       
				__________________ My gaming placement | |
|   |   | 
|  30-12-2005, 11:12 | #8 | 
| Senior Member Iscritto dal: May 2004 Città: Padova 
					Messaggi: 2221
				 | 
		l'importante è avere competenze pratiche e teoriche che ti permettano di programmare efficentemente..!! Uno può essere anche un autodidatta e saper fare + di tutti alla fine!! Basta aver voglia di imparare secondo me... 
				__________________ http://www.flickr.com/photos/dnamat/ | 
| ![DnA[TF] è offline](images_hwu/statusicon/user_offline.gif)  |   | 
|  30-12-2005, 16:21 | #9 | |
| Senior Member Iscritto dal: May 2005 Città: Roma 
					Messaggi: 7938
				 | Quote: 
     
				__________________ My gaming placement | |
|   |   | 
|   | 
| Strumenti | |
| 
 | 
 | 
Tutti gli orari sono GMT +1. Ora sono le: 04:30.









 
		 
		 
		 
		![L'Avatar di DnA[TF]](customavatars/avatar72953_3.gif)








 
  
 



 
                        
                        










