programaÇÃo orientada a objetos

Olá galera, estou precisando de uma ajuda… Gostaria que alguém me ajudasse a criar um programinha orientado a objetos em linguagem JAVA.

Contendo:

CLASSE MAIN
… |
…V
CLASSE PESSOA (PAI)
…|…|
…|…|--------------------->CLASSE PROFESSOR
…V…|
CLASSE ALUNO…|
…|_________> CLASSE CURSO<|

( TENTEI FAZER UM DIAGRAMAZINHO DO PROJETO MAS FICOU MEIO ESQUISITO)

Algumas coisas sobre as classes:

->CLASSE PESSOA:

Nome:
Idade:
Sexo:

->CLASSE ALUNO

( Atributos da classe Pessoa(nome, idade, sexo)

  • Matricula

->CLASSE PROFESSOR

( Atributos da classe Pessoa(nome, idade, sexo)

  • Salário

->CLASSE CURSO

Nome
Carga Horaria

Bem eu fiz as classes MAIN, TELA, PESSOA, ALUNO, PROFESSOR E CURSO

CLASSE MAIN


import javax.swing.JOptionPane;
import java.util.ArrayList;
public class Main
{
    public static void main(String args[]){
         Tela tela = new Tela();
         tela.menu();
         System.exit(0);}


}[/code]

CLASSE TELA

(Essa classe serve para impressão de tela, uso BlueJ e com array list na classe main da uns erros ai fiz assim)

[code]
import javax.swing.JOptionPane;
import java.util.ArrayList;
import java.text.*;
public class Tela
{
    private ArrayList<Curso> cursos=new ArrayList<Curso>();
    private ArrayList<Aluno> alunos=new ArrayList<Aluno>();
    private ArrayList<Professor> professores = new ArrayList<Professor>();
    
    public void menu()
    {
        int menu;
        do
        {
            menu=Integer.parseInt(JOptionPane.showInputDialog("PROGRAMAÇÃO ORIENTADA A OBJETOS\n\n1 - Cadastrar cursos\n2 - Listar cursos\n3 - Cadastrar aluno\n4-Listar alunos\n5 - Cadastrar professor\n6 - Listar Professores\n\n-----------[ DIGITE A OPÇãO ]--------\n\n"));
            
            switch(menu)
            {
                case 1:
                    this.cadastrarCurso();
                    break;
                case 2:
                     this.listarCursos();
                     break;
                case 3:
                    this.cadastrarAluno();
                    break;
                case 4: 
                    this.listarAlunos();
                    break;
                case 5:
                    this.cadastrarProfessor();
                    break;
                case 6:
                    this.listarProfessores();
                    break;
            }
            
            
        } while (menu!=0);
        
        
    }
    
    public void cadastrarCurso()
    {
        String nome = JOptionPane.showInputDialog("Digite o nome do Curso: ");
        int carga = Integer.parseInt(JOptionPane.showInputDialog("Digite a Carga horária do curso"));
        
        cursos.add(new Curso(nome, carga));
        
        
    }
    
    public void listarCursos()
    {
        int i;
        String lista="";
        
        for(i=0; i<cursos.size(); i++)
        {
            lista+="Código: "+i+"\n"+cursos.get(i).toString()+"\n";
        }
        
        JOptionPane.showMessageDialog(null,lista);
    }
    
    public void cadastrarAluno()
    {
        int codigo;
        
        
        codigo=Integer.parseInt(JOptionPane.showInputDialog("Digite o código do curso"));
        
        String nome = JOptionPane.showInputDialog("Digite o nome do aluno");
        int idade = Integer.parseInt(JOptionPane.showInputDialog("Digite a idade"));
        String sexo = JOptionPane.showInputDialog("Digite o sexo");
        int matricula = Integer.parseInt(JOptionPane.showInputDialog("Digite a matricula"));
        
        cursos.get(codigo).inserirAluno(new Aluno(nome, idade, sexo, matricula));
    }
    
    public void listarAlunos()
    {
        int codigo,i;
        String lista="";
        codigo=Integer.parseInt(JOptionPane.showInputDialog("Digite o código do curso"));
        
        alunos=cursos.get(codigo).getAlunos();
        
        for(i=0; i<alunos.size(); i++)
        {
            lista+=alunos.get(i).toString()+"\n";
        }
        
        JOptionPane.showMessageDialog(null, lista);
    }
    
    public void cadastrarProfessor()
    {
        int codigo;
        
        
        codigo=Integer.parseInt(JOptionPane.showInputDialog("Digite o código do curso"));
        
        String nome = JOptionPane.showInputDialog("Digite o nome do professor");
        int idade = Integer.parseInt(JOptionPane.showInputDialog("Digite a idade"));
        String sexo = JOptionPane.showInputDialog("Digite o sexo");
        double salario = Double.parseDouble(JOptionPane.showInputDialog("Digite o salário"));
        
        cursos.get(codigo).inserirProfessor(new Professor(nome, idade, sexo, salario));
    }
    
    public void listarProfessores()
    {
        int codigo,i;
        String lista="";
        codigo=Integer.parseInt(JOptionPane.showInputDialog("Digite o código do curso"));
        
        professores=cursos.get(codigo).getProfessores();
        
        for(i=0; i<professores.size(); i++)
        {
            lista+=professores.get(i).toString()+"\n";
        }
        
        JOptionPane.showMessageDialog(null, lista);
    }
    
}[/code]

CLASSE PESSOA

(ESSA SERÁ A CLASSE PAI DE ALUNO E PROFESSOR)


[code]
import javax.swing.JOptionPane;
public class Pessoa
{
    private String nome;
    private int idade;
    private String sexo;

public Pessoa(String nome,int idade, String sexo){
    this.nome=nome;
    this.idade=idade;
    this.sexo=sexo;
    
    
}

public void setNome(String nome){
    this.nome=nome;}

    
public void setIdade(int idade){
    this.idade=idade;}
    
public void setSexo(String sexo){
    this.sexo=sexo;}
   
public String getNome(){return nome;}
public int getIdade(){return idade;}
public String getSexo(){return sexo;}
    
}
[/code]

CLASSE ALUNO

[code]public class Aluno extends Pessoa
{
   private int matricula;

   public Aluno(String nome, int idade, String sexo, int matricula)
   {
       super (nome, idade, sexo);
       this.matricula=matricula;
   }
       

public void setMatricula( int matricula ){
    this.matricula=matricula;}

public int getMatricula(){return this.matricula;}



public String toString(){

    return "Nome: " + getNome() + "\nIdade: " + getIdade() + "\nSexo: " + getSexo() + "\nMatricula: " + getMatricula();}

}
[/code]

CLASSE PROFESSOR

[code]public class Professor extends Pessoa{

private double salario;

   public Professor(String nome, int idade, String sexo, double salario)
   {
       super (nome, idade, sexo);
       this.salario=salario;
       
   }

public void setSalario( double salario ){
    this.salario=salario;}

public double getSalario(){return this.salario;}

public String toString(){return
                "Nome: " + getNome() 
                + "\nIdade: " + getIdade() 
                + "\nSexo: " + getSexo() 
                + "\nSalario: " + getSalario();
            }
}

CLASSE CURSO
(A classe aluno e professor relacionam com curso)

[code]import java.util.ArrayList;
public class Curso
{
private ArrayList professores = new ArrayList();
private ArrayList alunos = new ArrayList();
private String nome;
private int carga;

public Curso(String nome, int carga)
{
this.nome = nome;
this.carga = carga;
}
public void setNome (String nome){
this.nome = nome;
}

public void setCarga (int carga){
this.carga = carga;
}

public String getNome (){
    return nome;
}
public int getCarga(){ 
    return carga;
}

public void inserirAluno(Aluno aluno)
{
       alunos.add(aluno);
}

public ArrayList<Aluno> getAlunos()
{
    return this.alunos;
}

public void inserirProfessor(Professor professor)
{
       professores.add(professor);
}

public ArrayList<Professor> getProfessores()
{
    return this.professores;
}

public String toString()
{
    return "Nome: "+this.nome+"\nCarga Horária"+this.carga;
}

}[/code]

EU FIZ COM QUE O USUÁRIO:

  • CADASTRE CURSO
    -LISTE CURSOS
    -CADASTRE ALUNO
    -LISTE ALUNOS
    -CADASTRE PROFESSOR
    -LISTE PROFESSORES

AGORA EU GOSTARIA QUE ALGUÉM ME AJUDASSE A FAZER PARA:

*BUSCAR ALUNO (PODE SER PELO CODIGO DO ALUNO), MOSTRANDO SEUS DADOS E O CURSO QUE FAZ.

*BUSCAR PROFESSOR(PODE SER PELO CODIGO DO PROFESSOR), MOSTRANDO SEUS DADOS E O CURSO QUE LECIONA

Você já fez algum código?

Se fez posta para pessoal ver onde que está enroscando.

Mano isso é extremamente facil… Não irei falar a resposta pôs perderia a graça. www.caelum.com.br baixe a apostila fj-11 de lá e leia.
Abraço.