0

I created a little beginners program, and its about a Telephone network which has an operator and three clients: i made four classes, and it gives me error at planta and cliente

In cliente it gives error on public class cliente private operadora
Im Planta it gives me error in the fourth line

Pleaase Help!

1. Main Class

package mensajes;
public class Main {

    public static void main(String[] args) {
        Cliente c1 = new Cliente();            
        Cliente c2 = new Cliente ();
        Cliente c3 = new Cliente ();
        c1.setNombre("Julio");
        c1.setTelefono("12345678");
        c2.setNombre("Ana");
        c2.setTelefono("97812344");
        c3.setNombre("Gema");
        c3.setTelefono("45678922");
        Operadora op= new Operadora();
        op.suscribir(c1, c2, c3);
        c1.registrarOperadora(op);
        c2.registrarOperadora(op);
        c3.registrarOperadora(op);
        op.ponerTiempo(20);
        c1.llamar("1", 5);



    }

}

Cliente class

public class Cliente

{
private String nombre;
private String telefono;
private Operadora  op;
public void setNombre(String n){nombre=n;}
public void setTelefono (String t){telefono=t;}
public String getNombre(){return nombre;}
public String getTelefono (){return telefono;}
public void registrarOperadora(Operadora ref)
{
    op=ref;
}
public void llamar(String n, float t)
    {
     op.llamar(n,t);

}
public void responder()
    {
  JOptionPane.showMessageDialog(null,
          "Hola mi nombre es "+nombre+
          "y mi numero es "+telefono);
}


}

Plant Class

package mensajes;
public class Planta {
    private float tiempoAire;
    Cliente c1, c2, c3;   //
    public void setTiempo (float t){tiempoAire+=t;}
    public float getTiempo (){return tiempoAire;}
    public void suscribir (Cliente a, Cliente b, Cliente c)
    {
    c1 =a; c2=b; c3=c;
    }

public void llamar (String n, float t)

{
     this.tiempoAire-=t;
     if(c1.getNombre()==n)
         c1.responder();

else
    if (c2.getNombre()==n)
        c2.responder();

else
    c3.responder();

}
}

Operadora class

package mensajes;
import javax.swing.JOptionPane;
public class Operadora {
    private Planta p = new Planta (); //composicion
public void suscribir (Cliente a, Cliente b, Cliente c)
    {
    p.suscribir(a, b, c);
    }
public void llamar (String n, float t)
    {
    if(p.getTiempo()<t)
        JOptionPane.showMessageDialog(null,
                "Su llamada no puede realizarse. "+
                "El tiempo disponible es: " +
                p.getTiempo());

    else
        p.llamar(n, t);
}
public void  ponerTiempo(float t)
    {
   p.setTiempo(t);
}



}
2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by kramerd
0

I had to add 2 lines to Cliente.java:

package mensajes;

import javax.swing.*;

Then the code compiled & ran. I did not see the errors you mention above.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.