Jump to content

Manipulação de vector


Pedro Xavier
 Share

Recommended Posts

Boas, alguem me podia explicar como fazer este exercicio? é que não estou a ter nenhuma ideia :......

EXERCICIO:

Crie uma classe BicycleManagment que armazene um vetor de bicicletas (Bicycle[]). Crie um método para adicionar bicicletas ao vetor até a um máximo de 20. De seguida e utilizando a classe BikeDemo, teste a classe criada, adicionando as bicicletas que criou na alínea 1.1. Crie ainda um método na classe BicycleManagment, que imprima todos os dados das bicicletas contidas no vetor que criou.

vou deixar aqui as minhas classes já utilizadas

public class Bicycle {
private int id;
private int numberOfGears;
private String mainColor;
private float weelSize;
private float bikeLength;
private boolean adjustableSeatpost;
private float price;

public Bicycle(int id, int numberOfGears, String mainColor, float weelSize, float bikeLength, boolean adjustableSeatpost, float price){
this.id = id;
this.numberOfGears = numberOfGears;
this.mainColor = mainColor;
this.weelSize = weelSize;
this.bikeLength = bikeLength;
this.adjustableSeatpost = adjustableSeatpost;
this.price = price;
}

public int getId() {
return id;
}

public void setId(int id) {
this.id = id;
}

public int getNumberOfGears() {
return numberOfGears;
}

public void setNumberOfGears(int numberOfGears) {
this.numberOfGears = numberOfGears;
}

public String getMainColor() {
return mainColor;
}

public void setMainColor(String mainColor) {
this.mainColor = mainColor;
}

public float getWeelSize() {
return weelSize;
}

public void setWeelSize(float weelSize) {
this.weelSize = weelSize;
}

public float getBikeLength() {
return bikeLength;
}

public void setBikeLength(float bikeLength) {
this.bikeLength = bikeLength;
}

public boolean isAdjustableSeatpost() {
return adjustableSeatpost;
}

public void setAdjustableSeatpost(boolean adjustableSeatpost) {
this.adjustableSeatpost = adjustableSeatpost;
}

public float getPrice() {
return price;
}

public void setPrice(float price) {
this.price = price;
}

}

public class MountainBike extends Bicycle {
private int NumberOfLigths;
private MountainBikeSuspension suspension;
private BikeTools[] bikeTools;

public MountainBike(int id, int numberOfGears, String mainColor, float weelSize, float bikeLength, boolean adjustableSeatpost, float price, int NumberOfLigths, MountainBikeSuspension suspension, BikeTools[] bikeTools) {
super(id, numberOfGears, mainColor, weelSize, bikeLength, adjustableSeatpost, price);
this.NumberOfLigths = NumberOfLigths;
this.suspension = suspension;
this.bikeTools = bikeTools;

}

public void ImprimirFerramentas(){
for(Object m1 : bikeTools){
if(m1 instanceof BikeTools){
BikeTools M = (BikeTools) m1;

System.out.println("ID: " + M.getId());
System.out.println("NAME: " + M.getTool());
}
}
}

public int getNumberOfLigths() {
return NumberOfLigths;
}

public void setNumberOfLigths(int NumberOfLigths) {
this.NumberOfLigths = NumberOfLigths;
}

public MountainBikeSuspension getSuspension() {
return suspension;
}

public void setSuspension(MountainBikeSuspension suspension) {
this.suspension = suspension;
}

public BikeTools[] getBikeTools() {
return bikeTools;
}

public void setBikeTools(BikeTools[] bikeTools) {
this.bikeTools = bikeTools;
}



}

tenho mais classes, para outro tipo de bicicletas e ferramentas....

Mas o que me aconselham??

Cumprimentos

eu já tenho criadas as bicicletas num BikeDemo, só falta manda las para o BicYcleManagment

Edited by apocsantos
geshi
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.