Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
Tags
- dfs
- String
- DP
- c++
- Tutorial
- 백준
- 문제풀이
- loop
- github
- Class
- guide
- parameter
- Basic
- w3school
- 프로그래밍
- 시작해요 언리얼 2022
- 재귀
- 파이썬
- 기초
- Programming
- dynamic
- Unreal Engine 5
- Material
- 오류
- python
- C#
- W3Schools
- Unity
- UE5
- Algorithm
Archives
- Today
- Total
행복한 개구리
C# 21.03.10.과제 3 본문
3-1~10
반환타입x/매개변수x
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Study00
{
class Program
{
static void Main(string[] args)
{
TurnOnAutoRun();
StartMatchParty();
StopAction();
ExecuteEscape();
BeHit();
ExecuteCounterAttack();
KeepPracticing();
StandUp();
SendMessage();
ServerDelay();
}
//자동달리기
static private void TurnOnAutoRun()
{
Console.WriteLine("자동 달리기가 활성화되었습니다.");
}
//파티매칭
static private void StartMatchParty()
{
Console.WriteLine("파티매칭이 시작되었습니다.");
}
//행동멈추기
static private void StopAction()
{
Console.WriteLine("하고있던 행동을 멈춥니다.");
}
//탈출
static private void ExecuteEscape()
{
Console.WriteLine("위치에서 탈출합니다.");
}
//피격
static private void BeHit()
{
Console.WriteLine("피격 당했습니다.");
}
//반격
static private void ExecuteCounterAttack()
{
Console.WriteLine("카운터공격을 시전합니다.");
}
//연습
static private void KeepPracticing()
{
Console.WriteLine("연습을 계속합니다.");
}
//기상
static private void StandUp()
{
Console.WriteLine("자리에서 일어납니다.");
}
//메시지 전송
static private void SendMessage()
{
Console.WriteLine("메시지를 보냈습니다.");
}
//서버 지연
static private void ServerDelay()
{
Console.WriteLine("서버가 지연되고 있습니다.");
}
}
}
============================================================================
3-11~17
반환타입x/매개변수o
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Study00
{
class Program
{
static void Main(string[] args)
{
TurnOnAutoRun("ON");
StartMatchParty("M");
AttackAndDodge(4, "공격");
Enhance("단도", 0, 5000);
ChangeDestination("마을");
VendingMachine(2, 1000);
}
//자동달리기
static private void TurnOnAutoRun(string a)
{
if (a == "27")
{
Console.WriteLine("자동달리기를 켭니다.");
}
else
{
Console.WriteLine("자동달리기를 끕니다.");
}
}
//파티매칭
static private void StartMatchParty(string a)
{
if (a == "M")
{
Console.WriteLine("파티매칭을 시작합니다.");
}
else if (a == "C")
{
Console.WriteLine("파티매칭을 취소합니다.");
}
else
{
Console.WriteLine("잘못 입력했습니다.");
}
}
//공격 및 회피
static private void AttackAndDodge(int a, string b)
{
if (b == "공격")
{
if (a == 4)
{
Console.WriteLine("콤보어택이 발동됐습니다. 2번 추가타를 가합니다. 당분간 콤보어택이 발동하지 않습니다.");
}
else if (a > 5 || a < 0)
{
Console.WriteLine("잘못된 입력입니다. 다시 입력하세요. (공격가능 횟수 : 1~4)");
}
else
{
Console.WriteLine("당신은 {0}번 {1}합니다", a, b);
}
}
else if (b == "회피")
{
if (a > 3 || a < 0)
{
Console.WriteLine("잘못된 입력입니다. 다시 입력하세요. (최대 회피거리 : 2보)");
}
else
{
Console.WriteLine("당신은 {0}보 {1}합니다.", a, b);
}
}
else
{
Console.WriteLine("잘못된 입력입니다.");
}
}
//강화
static private void Enhance(string name, int firstEnhanceNum, int gold)
{
int enhanceNum = firstEnhanceNum;
int i = 0;
while (i < 1)
{
if (gold >= 2500)
{
Random rand = new Random();
int num = rand.Next(1, 101);
if (num > 50)
{
gold -= 2500;
Console.WriteLine("강화를 시도합니다. 남은 골드 : {0}", gold);
enhanceNum += 1;
Console.WriteLine("강화에 성공했습니다. 현재 강화수치 : {0}", enhanceNum);
}
else
{
gold -= 2500;
Console.WriteLine("강화를 시도합니다. 남은 골드 : {0}", gold);
Console.WriteLine("강화에 실패했습니다.");
}
}
else
{
Console.WriteLine("강화 비용이 부족합니다. 연속강화를 마칩니다.");
break;
}
}
}
//목적지 변경
static private void ChangeDestination (string a)
{
string destination = a;
switch (destination)
{
case "던전":
Console.WriteLine("{0}으로 향합니다.", a);
break;
case "마을":
Console.WriteLine("{0}으로 향합니다.", a);
break;
case "결투장":
Console.WriteLine("{0}으로 향합니다.", a);
break;
}
}
//자판기
static private void VendingMachine(int num, int money)
{
int button = num;
int numPrice1 = 1000;
int numPrice2 = 1500;
int change = money;
if (money >= 1500)
{
if (button == 1)
{
change -= numPrice1;
Console.WriteLine("상품명 : 생수 / 가격 : {0} / 잔돈 : {1}", numPrice1, change);
}
else if (button == 2)
{
change -= numPrice2;
Console.WriteLine("상품명 : 이온음료 / 가격 : {0} / 잔돈 : {1}", numPrice2, change);
}
}
else if (money < 1500 && money >= 1000)
{
if (button == 1)
{
change -= numPrice1;
Console.WriteLine("상품명 : 생수 / 가격 : {0} / 잔돈 : {1}", numPrice1, change);
}
else if (button == 2)
{
Console.WriteLine("금액이 부족합니다.");
}
}
else
{
Console.WriteLine("금액이 부족합니다.");
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Study00
{
class Program
{
static void Main(string[] args)
{
Enhance("단도", 0, 500000);
}
//강화확률 변동
static private void Enhance(string name, int firstEnhanceNum, int gold)
{
int enhanceNum = firstEnhanceNum;
string itemName = name;
for (int a = 0; a < 20; a++)
{
if (gold >= 2500)
{
if (enhanceNum < 6 && enhanceNum >= 0)
{
enhanceNum += 1;
Console.WriteLine("{0} 강화에 성공했습니다. 강화수치 : {1}", itemName, enhanceNum);
}
else if (enhanceNum < 11 && enhanceNum > 5)
{
Random rand = new Random();
float num = rand.Next(1, 101);
float possibility = (100 / (float)enhanceNum) * 5;
if (possibility > num)
{
enhanceNum += 1;
Console.WriteLine("{0} 강화에 성공했습니다. 강화수치 : {1}", itemName, enhanceNum);
}
else
{
Console.WriteLine("강화에 실패했습니다.");
}
}
else if (enhanceNum >= 11)
{
Random rand = new Random();
float num = rand.Next(1, 101);
float possibility = 50 / (float)enhanceNum * 7;
if (possibility > num)
{
enhanceNum += 1;
Console.WriteLine("{0} 강화에 성공했습니다. 강화수치 : {1}", itemName, enhanceNum);
}
else
{
Console.WriteLine("강화에 실패했습니다.");
}
}
else if (enhanceNum <= 20)
{
Console.WriteLine("최대 강화수치입니다. (최대 강화수치 : 20)");
break;
}
}
else if (gold < 2500 || gold >= 0)
{
Console.WriteLine("강화비용이 부족합니다.");
gold += 2500;
break;
}
gold -= 2500;
Console.WriteLine("남은 골드 : {0}", gold);
}
}
}
}
출력값
============================================================================
3-18~27
반환타입o/매개변수x
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Study00
{
class Program
{
static void Main(string[] args)
{
bool amILucky = Gacha();
Console.WriteLine("Am I lucky? {0}", amILucky);
string itemName = EquipmentName();
Console.WriteLine("고블린이 {0}을 장착하였습니다.", itemName);
int monsterSpeed = MonsterSpeed();
Console.WriteLine("고블린의 이동속도가 {0}로 상승합니니다.", monsterSpeed);
bool someViolenceJust = isNot();
Console.WriteLine("때때로 폭력은 정의로운가? : {0}", someViolenceJust);
string nerfGildong = UnequipItem();
Console.WriteLine("홍길동에게서 {0}를 장착해제합니다.", nerfGildong);
int heroSpeed = MoveSpeed();
Console.WriteLine("홍길동의 이동속도가 {0}로 하락합니다.", heroSpeed);
string monsterFollow = HeroChase();
Console.WriteLine("{0}이 홍길동을 쫓아갑니다.", monsterFollow);
bool canHit = Hit();
Console.WriteLine("고블린이 공격합니다. 공격 성공여부 : {0}", canHit);
bool critical = CriticalAttack();
Console.WriteLine("공격 치명타여부 : {0}", critical);
bool isHeDie = IsGildongAlive();
Console.WriteLine("홍길동 사망여부 : {0}", isHeDie);
}
//옛날 문방구 앞 뽑기
static private bool Gacha()
{
Random rand = new Random();
float num = rand.Next(0, 101);
if (num > 90)
{
bool myLuck = true;
return myLuck;
}
else
{
bool myLuck = false;
return myLuck;
}
}
//장비 장착
static private string EquipmentName()
{
string itemName = "신속의 장화";
return itemName;
}
//고블린 이속증가
static private int MonsterSpeed()
{
int unitSpeed = 5;
return unitSpeed;
}
//사상 검증(확률)
static private bool isNot()
{
Random rand = new Random();
int num = rand.Next(1, 101);
if (num > 99)
{
bool isViolenceJust = true;
return isViolenceJust;
}
else
{
bool isViolenceJust = false;
return isViolenceJust;
}
}
//홍길동 너프안
static private string UnequipItem()
{
string itemName = "홍길동의 신발";
return itemName;
}
static private int MoveSpeed()
{
int speed = 4;
return speed;
}
//쫓기는 홍길동
static private string HeroChase()
{
string monsterName = "고블린";
return monsterName;
}
//공격 성공
static private bool Hit()
{
bool attackSuccessfully = true;
return attackSuccessfully;
}
//치명타여부(확률)
static private bool CriticalAttack()
{
Random rand = new Random();
int num = rand.Next(1, 101);
if (num > 10)
{
bool isCritical = true;
return isCritical;
}
else
{
bool isCritical = false;
return isCritical;
}
}
//홍길동 생존여부
static private bool IsGildongAlive()
{
bool isHeroDie = false;
return isHeroDie;
}
}
}
============================================================================
3-28~30
반환타입o/매개변수x
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Study00
{
class Program
{
public enum eRace
{
Human,
Goblin
}
static void Main(string[] args)
{
//건물 건설
string complete = Building("야영지", "감시초소");
Console.WriteLine(complete);
//유닛합체(확률)
string combineResult = Combine("중급 고블린 쥴", "하급 고블린 나크쉬");
Console.WriteLine(combineResult);
//버프(확률)
bool buffSuccess = Buff("사용");
Console.WriteLine("버프 성공여부 : " + buffSuccess);
//지원군
}
//건물 건설
static private string Building(string bdName1, string bdName2)
{
Console.WriteLine("고블린이 활빈당 근처에 {0}와 {0}를 건설합니다.", bdName1, bdName2);
string buildings = "건설 완료";
return buildings;
}
//유닛합체(확률)
static private string Combine(string unitName1, string unitName2)
{
Random rand = new Random();
int num = rand.Next(1, 101);
if (num > 30)
{
Console.WriteLine("{0}과 {1}이 합체합니다. 고블린 백부장이 나왔습니다.", unitName1, unitName2);
string cResult = "합체 성공";
return cResult;
}
else
{
Console.WriteLine("{0}과 {1}이 합체합니다. 고블린 장군이 나왔습니다.", unitName1, unitName2);
string cResult = "합체 대성공";
return cResult;
}
}
//버프(확률)
static private bool Buff(string use)
{
if (use != "사용")
{
Console.WriteLine("잘못된 입력입니다. 다시 사용하세요.");
}
Random rand = new Random();
int num = rand.Next(1, 101);
if (num > 35)
{
Random rand2 = new Random();
int num2 = rand2.Next(0, 11);
int eft = num2;
Console.WriteLine("고블린 주술사가 버프를 {0}합니다. 데미지 {1}% 증가", use, eft);
bool isNice = false;
return isNice;
}
else
{
Random rand2 = new Random();
int num2 = rand2.Next(20, 51);
int eft = num2;
Console.WriteLine("고블린 주술사가 버프를 {0}합니다. 데미지 {1}% 증가", use, eft);
bool isNIce = true;
return isNIce;
}
}
//지원군(인원 랜덤)
private int Reinforcement()
}
}
'C# > 수업과제' 카테고리의 다른 글
C#21.03.15.과제 6 (0) | 2021.03.15 |
---|---|
C# 21.03.12~14.과제 5 (0) | 2021.03.12 |
C# 21.03.11.과제 4 (0) | 2021.03.12 |
C# 21.03.09.과제 2 (0) | 2021.03.09 |
C# 과제 21.08.20. 기본 데이터 형식 연습 (0) | 2021.03.08 |