Ciao ragazzi sono nuovo e mi trovo a scrivervi perche alcuni miei amici mi hanno parlato molto bene di voi.
vi chiedo un grande favore: io devo fare un esame universitario e devo portare un lavoro a piacere in java. il prof c'ha dato un lavoro simile ma io non ci sto capendo niente e per questo vi chiedo se qualcuno pazientemente mi potrebbe mettere dei commenti dopo ogni riga per capirci un po qualcosa.
il lavoro che devo portare consiste nel sostituire un metodo di calcolo nel lavoro che il professore ci ha dato ma questo avverrà dopo ora vorrei capire che mi sta facendo fare....
il programma che uso è netbeans6.1 (altra cosa assurda) e quando ho scritto il lavoro del professore mi da questo unico errore che non capisco:
.................................................. ..............................................
init:
deps-jar:
Compiling 1 source file to C:\Users\lele\Documents\NetBeansProjects\javaprofe ssore\build\classes
C:\Users\lele\Documents\NetBeansProjects\javaprofe ssore\src\javaprofessore\Main.java:88: class Computations is public, should be declared in a file named Computations.java
public class Computations {
1 error
BUILD FAILED (total time: 0 seconds)
.................................................. .................................................. ...
il lavoro che mi dovreste spiegare è questo:
package javaprofessore;
/**
*
* @author xxxxxxxxxxxxxxxx
*/
interface Framework {
public void Trasf(double xx[], double ff[]);
public void SetParam (double e, int It);
public double GetX (int k);
public double Precision ();
public int NumIter();}
abstract class Algorithm {
int m , n ;
double eps ;
double test ;
int Itmax ;
int kount ;
double x[] ;
double f[] ;
double stack [] ;
Method Z ;
Algorithm(int nn, int mm) {
n = nn ;
m = mm ;
stack = new double[m+1];
x = new double [n+1];
f = new double [n+1]; }
void Iterations () {
int i, k ;
double xnew, dx ;
boolean end ;
kount = 0 ;
end = false ;
while (!end)
{ test = 0. ;
for ( k=1 ; k<=n ; k++ )
{ dx = Z.compute(k,n,x,f);
if (Math.abs(dx)>test) test=Math.abs(dx);
xnew = x[k] - dx ;
if ((k-m)>0)
x[k-m] = stack[1];
for (i = 1 ; i<m ; i++ )
stack[i] = stack [i+1];
stack[m] = xnew ;}
for ( i=1 ; i<=m ; i++ )
x[n-m+i]= stack[i] ;
kount = kount + 1 ;
if (kount>Itmax | test<eps) end =true ; }}}
class Alg extends Algorithm implements Framework {
Alg(int nn, int mm) {
super(nn,mm);
Method W =new Method ();
super.Z = W ; }
public void SetParam (double e, int It) {
super.eps = e ;
super.Itmax = It;}
public void Trasf (double [] xx, double [] ff) {
super.x = xx ;
super.f = ff ; }
public double Precision() {
return super.test ; }
public int NumIter() {
return super.kount ; }
public double GetX(int k) {
return super.x[k]; }}
class Method {
public double compute (int k, int n, double [] x, double[] f){
double y ;
y = x[k]-f[k] ;
if ( (k-1)>=1 ) y = y-x[k-1]/4 ;
if ((k+1)<=n) y = y-x[k+1]/4 ;
return y ; }}
public class Computations {
public static void main(String[] args ) {
Alg Jacobi ;
int i, n, m ;
double x[] = new double [11] ;
double f[] = new double [11] ;
n=10;
m=2;
for ( i=1; i<=n ; i++ )
{x[i] = 0. ;
f[i] = 0. ; }
f[1] = 6. ;
f[2] = 10. ;
f[3] = -3. ;
f[4] = -2. ;
f[5] = 1. ;
f[10] = 2. ;
Jacobi =new Alg(n,m) ;
Jacobi.Trasf(x, f) ;
Jacobi.SetParam(0.0001,100) ;
Jacobi.Iterations () ;
System.out.println("Iteration Num. " + Jacobi.NumIter());
System.out.println("Max.Correction " + Jacobi.Precision());
for ( i=1 ; i<=n ; i++ )
System.out.println("X["+i+"]= " + Jacobi.GetX(i));
System.out.println("End!") ; } }
grazie mille in anticipo.....