C# おにゃんこ大戦争

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CharactorMove : MonoBehaviour
{
public enum TYPE
{
PLAYER,
ENEMY,
}
public TYPE type = TYPE.PLAYER;

float direction;
Vector3 pos;

bool isMove = true;

// Start is called before the first frame update
void Start()
{
    switch(type)
    {
        case TYPE.PLAYER:
            //Player時の処理
            direction = -1;
            break;
        case TYPE.ENEMY:
            //Enemyの時の処理
            direction = 1;
            break;
    }
    pos = new Vector3(direction, 0, 0);
}

// Update is called once per frame
void Update()
{
    if(isMove)
    {
        transform.position += pos * Time.deltaTime;
    }
}
private void OnTriggerEnter2D(Collider2D collision)
{
    //敵にぶつかったら移動とめる
    if(collision.gameObject.tag == "Enemy" && type == TYPE.PLAYER
        || collision.gameObject.tag == "Player" && type == TYPE.ENEMY)
    {
        isMove = false;
    }
    //攻撃をしはじめる
}
private void OnTriggerExit2D(Collider2D collision)
{
    if (collision.gameObject.tag == "Enemy" && type == TYPE.PLAYER
       || collision.gameObject.tag == "Player" && type == TYPE.ENEMY)
    {
        isMove = true;
    }
}

}

C++ ポケモン

include

class Pokemon {
public:
// コンストラクタ
Pokemon(const std::string& nickname) {
this->nickname_ = nickname;
// nickname_ = nickname; と省略できる
}
// デストラクタ
virtual ~Pokemon() {
}
virtual void attack() = 0;
protected:
std::string nickname_;
};

class Pikachu : public Pokemon {
public:
Pikachu(const std::string& nickname) : Pokemon(nickname) {
}
virtual ~Pikachu() {
}
void attack() override {
std::cout << nickname_ << “の十万ボルト!” << std::endl;
}
};

class Zenigame : public Pokemon {
public:
Zenigame(const std::string& nickname) : Pokemon(nickname) {
}
virtual ~Zenigame() {
}
void attack() override {
std::cout << nickname_ << “のハイドロポンプ!” << std::endl;
}
};

int main() {
int i;
Pokemon* monsters[2];
monsters[0] = new Pikachu(“サトシのピカチュウ”);
monsters[1] = new Zenigame(“サトシのゼニガメ”);
std::cin >> i;
if (i >= 0 && i < 2) { monsters[i]->attack();
}
delete monsters[0];
delete monsters[1];
}

Python Todoリスト

class TodoList:
def init(self):
self.tasks = []

def add_task(self, task):
    self.tasks.append(task)

def remove_task(self, task):
    if task in self.tasks:
        self.tasks.remove(task)
    else:
        print("タスクが見つかりません。")

def list_tasks(self):
    if not self.tasks:
        print("ToDoリストは空です。")
    else:
        print("ToDoリスト:")
        for idx, task in enumerate(self.tasks, start=1):
            print(f"{idx}. {task}")

def main():
todo_list = TodoList()
while True:
print(“\n操作を選択してください:”)
print(“1. タスクを追加”)
print(“2. タスクを削除”)
print(“3. タスク一覧を表示”)
print(“4. 終了”)
choice = input(“選択: “)

    if choice == '1':
        task = input("タスクを入力してください: ")
        todo_list.add_task(task)
        print("タスクが追加されました。")

    elif choice == '2':
        task_idx = int(input("削除するタスクの番号を入力してください: "))
        if 1 <= task_idx <= len(todo_list.tasks):
            task_to_remove = todo_list.tasks[task_idx - 1]
            todo_list.remove_task(task_to_remove)
            print("タスクが削除されました。")
        else:
            print("無効な番号です。")

    elif choice == '3':
        todo_list.list_tasks()

    elif choice == '4':
        print("プログラムを終了します。")
        break

    else:
        print("無効な選択です。")

if name == “main“:
main()