Ich habe eine Zuordnung, wo ich die abstrakte Klassennummer verwenden muss, um den Wert mit den Methoden in der Klasse Nummer auszudrucken. HierPI-Zuweisung mit abstrakter Klassennummer
ist der Code, der gegeben ist und ich habe nur die Methoden verwenden, um den PI-Wert zu drucken:
public class Pi extends Number {
public static double PI = 3.14159265358979323846264338327950;
private int intValue; // PI rounded down to nearest int
private long longValue; // PI rounded up to nearest int
private float floatValue; // PI as type float
private double doubleValue; // PI as defined
/*
* TBI (To Be Implemented)
* The constructor assigns values to all of the instance
* variables defined above. The values that are assigned
* to the instance variables are documented using comments
* when the instance variables are defined.
*/
public Pi() {
// the expressions on the right side of each of the following
// assignment statements must use PI in them...
intValue = ;
longValue = ;
floatValue = ;
doubleValue = ;
}
/*
* TBI (To Be Implemented)
* Returns a String representation of this Pi object
* that is used as the output of this progam.
*/
public String toString() {
}
/*
* The following methods cannot be modified/deleted.
*/
public static void main(String[] argv) {
System.out.println(new Pi());
}
public double getPi() { return doubleValue; }
}
/*
* the output of the program must look something like the following
*
byteValue(): 3
shortValue(): 3
intValue(): 3
longValue(): 4
floatValue(): 3.1415927
doubleValue(): 3.141592653589793
*
*/
Ich bin gerade eine harte Zeit beginnt diese mit. Ich möchte nicht, dass irgendjemand das Programm macht, bitte hilf mir, anzufangen und den Konstruktor und die Methode zu implementieren.
ist Ihre Frage, wie man ein 'doppeltes' in ein 'int' umwandelt? –
@ScaryWombat Ich bin mir nicht sicher, wie ich anfangen soll, ich lese durch die Klassennummer und es sagt, der Konstruktor ist nur öffentliche Nummer(). Wie kann ich das in meinen Code einfügen? –
Ich schlage vor, Sie gehen zurück und bitten um Klarstellung –