-4
I want to create a program that uses interfaces to create a vector class with name and size and have the methods below:
<> +Definirnometamanhovetor +PreencherVetorCriadoInformandoPosicaoValor +Orderer +Exibirvetor
I cannot pass the vector of a method to using the interface.
Follows the class of the vector: package classa06Cencapsulation training;
import java.util.Arrays;
public class Vetor Implements Interfacecontroladora {
private int posicaovetor = 0;
private int tamanhovetor = 0;
private String nomevetor = "";
/**
* @return the nome
*/
public String getNome() {
return nomevetor;
}
/**
* @param nome the nome to set
*/
public void setNome(String nome) {
this.nomevetor = nome;
}
/**
* @param posicao
* @param tamanho
*/
public Vetor(int posicao, int tamanho) {
super();
this.posicaovetor = posicao;
this.tamanhovetor = tamanho;
this.nomevetor = nomevetor;
}
/**
* @return the posicao
*/
private int getPosicao() {
return posicaovetor;
}
/**
* @param posicao the posicao to set
*/
private void setPosicao(int posicao) {
this.posicaovetor = posicao;
}
/**
* @return the tamanho
*/
private int getTamanho() {
return tamanhovetor;
}
/**
* @param tamanho the tamanho to set
*/
private void setTamanho(int tamanho) {
this.tamanhovetor = tamanho;
}
@Override
public void metodoDefinicaoVetor(String nomevetor, int tamanhovetor) {
// TODO Auto-generated method stub
setNome(nomevetor);
setTamanho(tamanhovetor);
int v[] = new int[getTamanho()];
Arrays.fill(v, 0);
System.out.println("Nome do vetor = " + getNome());
// Impressão dos valores dentro da posição do vetor.
for (int i = 0; i < v.length; i++) { //
System.out.printf(" " + v[i]);
}
System.out.println("");
}
@Override
public void metodoPreencimentoVetor() {
// TODO Auto-generated method stub
}
/*
* @Override public void metodoOrdenacaoVetor() { // TODO Auto-generated method
* stub int v[] = new int [getTamanho()]; Arrays.sort(v); }
*
* @Override public void metodoBuscarValorVetor() { // TODO Auto-generated
* method stub
*
* }
*/
}
I can’t pass the vector methodDefinicaViewer to the methodPreencimentViewer
How can I do that with this program? Can I link to git with my program here?
I didn’t understand the question. Before clarifying it, read a little about SOLID and Design Pattern maybe help you in reformulating.
– Augusto Vasques
Follow Main to understand what I need: package classes 06CencapsulationTraining; import java.io.Objectinputstream.Getfield; public class Programmain { /** * @param args */ public Static void main(String[] args) { // TODO Auto-generated method stub // Instantiating and creating a vector with name and size via constructor. Vector 1 = new Vector("created vector01", 5); // Defining the name and size of the new vector vector 1.methodDefiniVetor("created vector02", 3); vector 1.methodPreencimentoVetor(); //vector 1.methodOrdenacaoVetor(); } }
– Wesley Gomes da Silva
Important you [Dit] your question and explain objectively and punctually the difficulty found, accompanied by a [mcve] of the problem and attempt to solve. To better enjoy the site, understand and avoid closures and negativities worth reading the Stack Overflow Survival Guide in English.
– Bacco