x = $x; $this->y = $y; $this->z = $z; $this->addHistory(sprintf('%s,%s,%s,0,0,0', $this->getX(), $this->getY(), $this->getZ())); $this->velocity = new Velocity(0,0,0); } /** * @return int */ public function getX(): int { return $this->x; } /** * @param int $x * @return Moon */ public function setX(int $x): Moon { $this->x = $x; return $this; } /** * @return int */ public function getY(): int { return $this->y; } /** * @param int $y * @return Moon */ public function setY(int $y): Moon { $this->y = $y; return $this; } /** * @return int */ public function getZ(): int { return $this->z; } /** * @param int $z * @return Moon */ public function setZ(int $z): Moon { $this->z = $z; return $this; } /** * @return Velocity */ public function getVelocity(): Velocity { return $this->velocity; } /** * @param Velocity $velocity * @return Moon */ public function setVelocity(Velocity $velocity): Moon { $this->velocity = $velocity; return $this; } /** * @return string[] */ public function getHistory(): array { return $this->history; } /** * @param string $history * @return Moon */ public function addHistory($history): Moon { $this->history[] = $history; return $this; } public function saveHistory() { $velocity = $this->getVelocity(); $this->history[] = sprintf( '%s,%s,%s,%s,%s,%s', $this->getX(), $this->getY(), $this->getZ(), $velocity->getX(), $velocity->getY(), $velocity->getZ() ); return $this; } }