E ai galera blz, to com um probleminha to gerando um codigo com 2 classes, mas sempre da um erro na principal…
1º
import java.text.DecimalFormat;
//utilizado para formatar numero
//essa classe mantem a hora no formato 24hs
public class Time1 extends Object {
private int hour;
private int minute;
private int second;
public Time1()
{
setTime ( 0, 0, 0 );
}
AKI GERA UM ERRO syntax error on token "=", "Identifier" expected
-----> [color="red"]hour = ((h >= 0 && h < 24)? h : 0);[/color]
minute = ((m >= 0 && m < 60)? m : 0);
second = ((s >=0 && s < 60)? s : 0);
}
{
DecimalFormat twoDigits = new DecimalFormat (“00”);
return twoDigits.format (hour) + ":" +
twoDigits.format (minute)+ ":"+
twoDigits.format (second);
}
public String toString ()
{
DecimalFormat twoDigits = new DecimalFormat (“00”);
return (( hour == 12 || hour == 0)? 12 : hour % 12)+
":" + twoDigits.format (minute)+
":" + twoDigits.format (second)+
(hour < 12 ? "AM" : "PM");
}
public String toUniversalString() {
// Auto-generated method stub
return null;
}
public void setTime(int i, int j, int k ) {
//Auto-generated method stub
}
e a segunda classe
import javax.swing.JOptionPane;
public class TimeTest {
public static void main (String args [])
{
Time1 t= new Time1 (); // chama o construtor Time1
String output;
output = "The initial universal time is :" +
t.toUniversalString() +
"\nThe initial standard time is:" +
t.toString()+
"\nImplicit toString() call:" + t;
t.setTime (13 ,27, 6);
output += "\n\nUniversal time after setTime is:" +
t.toUniversalString()+
"\nStandard time after setTime is: " +
t.toString();
t.setTime (99 , 99, 99); //todos os valores invalidos
output += "n\\nAfter attempting invalid settings:"+
"\nUniversal time: " + t.toString();
JOptionPane.showMessageDialog (null, output,
"Testing Class Time1",
JOptionPane.INFORMATION_MESSAGE);
System.exit (0);
}
}