1. Day22

  • C++ 문법 학습
  • 알고리즘 코드카타
  • 과제 5 : Unreal Engine C++ 활용 프로그램 제작(해설 강의)
  • 과제 6: [CH2: 팀 프로젝트] 텍스트 콘솔 RPG 발제

2. C++ 문법 학습(Day22)

  • 알고리즘 코드카타
    • 두 수의 나눗셈
  • 과제 5 : Unreal Engine C++ 활용 프로그램 제작(해설 강의)
    • 함수명, 구현내용 등 지문 내에서 정해진 대로 할 것
  • 과제 6: [CH2: 팀 프로젝트] 텍스트 콘솔 RPG 발제

3. 과제 6: [CH2: 팀 프로젝트] 텍스트 콘솔 RPG 발제

  • 팀프로젝트 전 회의

4. 내일 계획 : 팀프로젝트 회의 및 역할 분담

1. Day21

  • C++ 문법 학습
  • 알고리즘 코드카타
  • CH2 학습 가이드 - 12/26

2. C++ 문법 학습(Day21)

  • 알고리즘 코드카타
    • 두수의 나눗셈

3. CH2 학습 가이드 - 12/26

  • 강의 3-3 과제 제출(배송 추적 시스템)
#include <iostream>
#include <vector>
#include <string>
using namespace std;

// 고객 인터페이스 (Observer 역할)
class Customer {
public:
    virtual void update(const string& status) = 0; // 순수 가상 함수
};

// 일반 고객 클래스
class RegularCustomer : public Customer {
private:
    string name;
public:
    RegularCustomer(const string& name) : name(name) {}

    void update(const string& status) {
        cout << "Regular customer " << name << " received update: " << status << endl;
    }
};

// TODO: VIP 고객 클래스 (Customer를 상속받아 구현)
// 요구 사항:
// - 고객 이름을 저장하는 멤버 변수 `name`을 추가하세요.
// - 생성자에서 이름을 초기화하세요.
// - `update` 메서드를 구현하여 "VIP customer [이름] received VIP update: [배송 상태]" 형식으로 출력되도록 하세요.
class VIPCustomer : public Customer {
private:
    string name;
public:
    VIPCustomer(const string& InName) : name(InName) {}

    void update(const string& status) {
        cout << "VIP customer " << name << " received VIP update: " << status << endl;
    }
};

class BusinessCustomer : public Customer {
private:
    string name;
public:
    BusinessCustomer(const string& InName) : name(InName) {}

    void update(const string& status) {
        cout << "Business Customer " << name << " received business update: " << status << endl;
    }
};

// TODO: 배송 회사 클래스 (DeliveryService)
// 요구 사항:
// - `customers`라는 고객 리스트를 저장하는 멤버 변수를 추가하세요.
// - `currentStatus`라는 현재 배송 상태를 저장하는 멤버 변수를 추가하세요.
// - 고객을 추가하는 `addCustomer` 메서드를 구현하세요.
// - 고객을 제거하는 `removeCustomer` 메서드를 구현하세요.
// - 배송 상태를 업데이트하고 모든 고객에게 알리는 `updateStatus` 메서드를 구현하세요.
// - 등록된 모든 고객에게 상태를 전달하는 `notifyCustomers` 메서드를 구현하세요.
class DeliveryService {
private:
    vector<Customer*> customers;
    string currentStatus;
public:
    void addCustomer(Customer* InCustomer)
    {
        if (InCustomer != nullptr)
        {
            customers.emplace_back(InCustomer);
        }
    }
    void removeCustomer(Customer* InCustomer)
    {
        auto it = find(customers.begin(), customers.end(), InCustomer);
        if (it != customers.end())
        {
            customers.erase(it);
        }

    }
    void updateStatus(const string& InStatus)
    {
        currentStatus = InStatus;
        notifyCustomers();
    }
    void notifyCustomers()
    {
        for (auto* C : customers)
        {
            C->update(currentStatus);
        }
    }
};
// Main 함수
int main() {
    DeliveryService service;

    // 고객 객체 생성
    RegularCustomer* customer1 = new RegularCustomer("Alice");
    VIPCustomer* customer2 = new VIPCustomer("Bob");
    BusinessCustomer* customer3 = new BusinessCustomer("CompanyX");

    // 고객 등록
    service.addCustomer(customer1);
    service.addCustomer(customer2);
    service.addCustomer(customer3);

    // 배송 상태 업데이트 및 알림
    cout << "Updating status: 배송 준비 중" << endl;
    service.updateStatus("배송 준비 중");
    // 고객 삭제 
    service.removeCustomer(customer2);
    // 배송 상태 업데이트 및 알림
    cout << "\nUpdating status: 배송 완료" << endl;
    service.updateStatus("배송 완료");

    // 메모리 해제
    delete customer1;
    delete customer2;
    delete customer3;

    return 0;
}

3. 다음주 계획 : 알고리즘 문제풀이, 과제5 코드정리 및 주석정리

1. Day20

  • C++ 문법 학습
  • 알고리즘 코드카타
  • C++ 레벨 테스트
  • CH2 학습 가이드 - 12/24
  • 과제 5 : Unreal Engine C++ 활용 프로그램 제작

2. C++ 문법 학습(Day20)

  • 게임 개발자를 위한 C++ 문법(3-2)
    • 언리얼 엔진 C++ 기본개념
  • 알고리즘 코드카타
    • 나이 출력, 숫자 비교하기, 두 수의 합
  • C++ 레벨 테스트
  • 과제 5 : Unreal Engine C++ 활용 프로그램 제작(도전 기능 완성)
    • MyActor.h/cpp
// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "MyActor.generated.h"

UCLASS()
class NBC_05_API AMyActor : public AActor
{
    GENERATED_BODY()

public:    
    // Sets default values for this actor's properties
    AMyActor();
protected:
    // Called when the game starts or when spawned
    virtual void BeginPlay() override;

public:    
    // Called every frame
    virtual void Tick(float DeltaTime) override;
    UFUNCTION()
    void RandMove();
    UFUNCTION()
    void RandRotate();
    UFUNCTION()
    int TriggerEventWithProbability(float Probability);
private:
    UPROPERTY()
    // 엑터의 회전
    FRotator ActorRotation;
    UPROPERTY()
    // 엑터의 위치
    FVector ActorLocation;

};

// Fill out your copyright notice in the Description page of Project Settings.


#include "MyActor.h"
#include "Engine/Engine.h"

// Sets default values
AMyActor::AMyActor()
{
     // Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
    PrimaryActorTick.bCanEverTick = true;

}

// Called when the game starts or when spawned
void AMyActor::BeginPlay()
{
    Super::BeginPlay();

    int32 RandomValue = FMath::RandRange(1, 100);
    int32 Probability = 50;
    float TotalDistance = 0.f;
    int32 EventCount = 0;

    if (IsValid(GEngine))
    {
        GEngine->AddOnScreenDebugMessage(-1, 50.0f, FColor::Black, 
            FString::Printf(TEXT("시작 위치 X = %f, Y = %f"), GetActorLocation().X, GetActorLocation().Y));
    }

    for (int i = 0; i < 10; i++)
    {
        if (RandomValue <= Probability)
        {
            FVector PrevLocation = GetActorLocation();
            RandMove();
            TotalDistance += FVector::Dist(PrevLocation, GetActorLocation());

            if (IsValid(GEngine))
            {
                GEngine->AddOnScreenDebugMessage(-1, 50.0f, FColor::Black, 
                    FString::Printf(TEXT("%d 번째, 위치 X = %f, Y = %f"), i + 1, GetActorLocation().X, GetActorLocation().Y));
            }
        }
        else
        {
            RandRotate();
            if (IsValid(GEngine))
            {
                GEngine->AddOnScreenDebugMessage(-1, 50.0f, FColor::Black, 
                    FString::Printf(TEXT("%d 번째, Yaw = %f°, Pitch = %f°"), i + 1, GetActorRotation().Yaw, GetActorRotation().Pitch));
            }
        }

        EventCount += TriggerEventWithProbability(50);
        RandomValue = FMath::RandRange(1, 100);

    }

    if (IsValid(GEngine))
    {
        GEngine->AddOnScreenDebugMessage(-1, 50.0f, FColor::Green, 
            FString::Printf(TEXT("총 이동거리: %f, 이벤트 발생: %d회"), TotalDistance, EventCount));
    }

}

// Called every frame
void AMyActor::Tick(float DeltaTime)
{
    Super::Tick(DeltaTime);

}

void AMyActor::RandMove()
{
    FVector RandomLocation;
    RandomLocation.X = FMath::RandRange(-100.f, 100.f);
    RandomLocation.Y = FMath::RandRange(-100.f, 100.f);

    SetActorLocation(GetActorLocation() + RandomLocation);
}


void AMyActor::RandRotate()
{
    FRotator RandomRotation;
    RandomRotation.Yaw = FMath::RandRange(0.f, 360.f);
    RandomRotation.Pitch = FMath::RandRange(0.f, 360.f);

    SetActorRotation(GetActorRotation() + RandomRotation);
}

int AMyActor::TriggerEventWithProbability(float Probability)
{
    int32 RandomValue = FMath::RandRange(1, 100);

    if (RandomValue <= Probability)
    {
        if (IsValid(GEngine))
        {
            GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Red, 
                TEXT("Event Triggered!"));
        }
        return 1;
    }
    else
    {
        if (IsValid(GEngine))
        {
            GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Red, 
                TEXT("Event Not Triggered"));
        }
        return 0;
    }
}

3. 내일 계획 : 크리스마스 휴일

+ Recent posts