
18/09/2014, 22:27
|
| | Fecha de Ingreso: septiembre-2014
Mensajes: 1
Antigüedad: 10 años, 5 meses Puntos: 0 | |
Me podrian ayudar con una converion de Java a Ruby Tengo que pasar un codigo de Java a Ruby pero soy nuevo en Ruby y no se como convertir la siguiente clase
public abstract class EnemyShipBuilding {
protected abstract EnemyShip makeEnemyShip(String typeOfShip);
public EnemyShip orderTheShip(String typeOfShip) {
EnemyShip theEnemyShip = makeEnemyShip(typeOfShip);
theEnemyShip.makeShip();
theEnemyShip.displayEnemyShip();
theEnemyShip.followHeroShip();
theEnemyShip.enemyShipShoots();
return theEnemyShip;
}
}
Alguien me podria ayudar a pasarlo a ruby, yo tengo el siguiente codigo pero esta mal la parte del @@temp ya que se tiene que referir a la misma clase pero no se como arreglarlo
require_relative 'EnemyShip'
class EnemyShipBuilding
def makeEnemyShip(typeOfShip)
return EnemyShip.new
end
def orderTheShip(typeOfShip)
@typeOfShip=typeOfShip
@@theEnemyShip=EnemyShip.new
@@temp = EnemyShipBuilding.new
@@theEnemyShip = @@temp.makeEnemyShip(@typeOfShip)
@@theEnemyShip.makeShip()
@@theEnemyShip.displayEnemyShip
@@theEnemyShip.followHeroShip
@@theEnemyShip.enemyShipShoots
return @@theEnemyShip
end
end |