ジョジョをC++化

2007/8/30

思いつきでジョジョクラスを書いてみました。 ですが、引越しの時に持っていた全巻を友人にあげてしまったので全然思い出せませんでした。 ごめんなさい。

あと、メンバ変数やメソッドが劇的に足りないと思います。 そもそもmainもないです。 どなたか捕捉して頂ければ幸いです。。。

BSDライセンスにしてみましたが、GPLの方が良いなどのご意見があれば変更します。 なお、ネタなので「こんなクソコードにライセンスつけるなよ!」という至極もっともな突っ込みはご遠慮願います。 念のため。



/*

Copyright (c) 2007, Geekなぺーじ

All rights reserved.

Redistribution and use in source and binary forms,
with or without modification, are permitted provided
that the following conditions are met:

Redistributions of source code must retain the
above copyright notice, this list of conditions
and the following disclaimer. 

Redistributions in binary form must reproduce
the above copyright notice, this list of conditions
and the following disclaimer in the documentation
and/or other materials provided with the distribution. 

Neither the name of the Geekなぺーじ nor the names
of its contributors may be used to endorse or promote
products derived from this software without specific
prior written permission. 

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

*/

#include <string>

typedef enum {
    SEX_UNKNOWN=0,
    SEX_MALE,
    SEX_FEMALE,
} sex;

class Person {
public:
  Person(bool bHamon,
	  bool bStand,
	  bool bHuman,
	  sex s) :
		m_bCanHamon(bHamon),
		m_bHaveStand(bStand),
		m_bIsHuman(bHuman),
		m_sex(s),
		HitPoint(65535)
  {
  }

  ~Person()
  {
  }

  void SetDamage(int val)
  {
	  HitPoint -= val;
	  if (HitPoint <= 0) {
		delete this;
	  }
  }

protected:
  bool m_bCanHamon;
  bool m_bHaveStand;
  bool m_bIsHuman;

  sex m_sex;

  int32_t HitPoint;
};

class Stand {
public:
	Stand(std::string n, Person *p) :
        name(n), hontai(p)
	{
	}

	~Stand()
	{
	}

	void SetDamage(int val)
	{
		assert(hontai != NULL);
		hontai->SetDamage(val);
	}

protected:
	std::string name;
	Person *hontai;
};

class JonathanJoestar : public Person {
public:
	JonathanJoestar() :
      Person(true, false, true, SEX_MALE)
  {
  }

  ~JonathanJoestar()
  {
    printf("ディオ…"
	"君のいうように"
	"ぼくらはやはり"
	"ふたりでひとりだったのかもしれないな"
	"奇妙な友情すら感じるよ"
        "そして今ふたりの運命は完全にひとつになった");
  }
};


class JosephJoestar;

class HermitPurple : public Stand {
friend class JosephJoestar;

public:
	HermitPurple(Person *p) :
		Stand("Hermit Purple", p)
	{
	}

	~HermitPurple() {}
};

class JosephJoestar : public Person {
public:
	JosephJoestar() :
		Person(true, false, true, SEX_MALE),
		hp(NULL)
	{
	}

	~JosephJoestar()
	{
	}

	void EnableDai3Wa()
	{
		m_bHaveStand = true;
		hp = new HermitPurple(this);
	}

private:
	HermitPurple *hp;
};


最近のエントリ

過去記事

過去記事一覧

IPv6基礎検定

YouTubeチャンネルやってます!