검색결과 리스트
프로그래밍에 해당되는 글 340건
- 2020.05.19 C# paiza 70 - 오버로드2
- 2020.05.19 C# paiza 69 - 오버로드1
- 2020.05.17 C# paiza 68 - String 클래스 가진 메소드 사용
- 2020.05.17 C# paiza 67 - 문자열, 배열도 오브젝트로
- 2020.05.17 C# paiza 66 - 억세서를 프로퍼티로 전환
- 2020.05.17 C# paiza 65 - 프로퍼티2
- 2020.05.17 C# paiza 64 - 생성된 오브젝트의 수 세기, 프로퍼티
- 2020.05.17 C# paiza 63 - 억세스 수식자 생략, Static
글
C# paiza 70 - 오버로드2
/////
// オーバーロードを理解しよう
using System;
class Lesson08
{
public static void Main()
{
Learning();
Learning("Ruby");
Learning("C#", "paiza");
}
static void Learning()
{
Console.WriteLine("私はプログラミングを学習した");
}
// 引数が1つのLearningメソッドを定義してください
static void Learning(string target)
{
Console.WriteLine("私は" + target + "を学習した");
}
// 引数が2つのLearningメソッドを定義してください
static void Learning(string target1, string target2)
{
Console.WriteLine("私は" + target1 + "を" + target2 + "で学習した");
}
}
///
///
/////
// オーバーロードを理解しよう
using System;
class Lesson08
{
public static void Main()
{
Run();
Run("箱根");
Run("400mトラック", 25);
}
static void Run()
{
Console.WriteLine("私は走った");
}
// 引数が1つのString型のRunメソッドを定義してください
static void Run(string target)
{
Console.WriteLine("私は" + target + "を走った");
}
// 引数が1つのString型と1つのint型のRunメソッドを定義してください
static void Run(string target, int num)
{
Console.WriteLine("私は" + target + "を" + num + "周走った");
}
}
/////////
'프로그래밍' 카테고리의 다른 글
C# paiza 72 - 표준 라이브러리 (0) | 2020.05.22 |
---|---|
C# paiza 71 - NameSpace (0) | 2020.05.19 |
C# paiza 69 - 오버로드1 (0) | 2020.05.19 |
C# paiza 68 - String 클래스 가진 메소드 사용 (0) | 2020.05.17 |
C# paiza 67 - 문자열, 배열도 오브젝트로 (0) | 2020.05.17 |
글
C# paiza 69 - 오버로드1
// オーバーロードを理解しよう
using System;
class Lesson08
{
public static void Main()
{
Attack(); //인수가 없으면 그냥
Attack("スライム"); //인수를 넣으면 아래로
}
static void Attack()
{
Console.WriteLine("勇者は、敵を攻撃した。");
}
static void Attack(string target)
{
Console.WriteLine("勇者は、" + target + "を攻撃した。");
}
}
/////////// 데이터의 오버로드
//////
// オーバーロードを理解しよう
using System;
class Lesson08
{
public static void Main()
{
Attack(); //인수가 없으면 그냥
Attack("スライム"); //인수를 넣으면 아래로
Attack(10); //인수에 숫자를 입력
}
static void Attack()
{
Console.WriteLine("勇者は、敵を攻撃した。");
}
static void Attack(string target)
{
Console.WriteLine("勇者は、" + target + "を攻撃した。");
}
static void Attack(int number)
{
Console.WriteLine("勇者は、" + number + "匹現れた");
}
}
///////
//////인수에 정수 대입
//////
//
///////
// オーバーロードを理解しよう
using System;
class Lesson08
{
public static void Main()
{
Attack(); //인수가 없으면 그냥
Attack("スライム"); //인수를 넣으면 두 번째로
Attack(10); //인수에 숫자를 입력
Attack("ドラゴン",3); //문자열과 숫자를 입력하면 맨 아래
}
static void Attack()
{
Console.WriteLine("勇者は、敵を攻撃した。");
}
static void Attack(string target)
{
Console.WriteLine("勇者は、" + target + "を攻撃した。");
}
static void Attack(int number)
{
Console.WriteLine("勇者は、" + number + "匹現れた");
}
static void Attack(string target, int number)
{
Console.WriteLine("勇者は、" + number + "匹の" + target + "を攻撃した");
}
}
'프로그래밍' 카테고리의 다른 글
C# paiza 71 - NameSpace (0) | 2020.05.19 |
---|---|
C# paiza 70 - 오버로드2 (0) | 2020.05.19 |
C# paiza 68 - String 클래스 가진 메소드 사용 (0) | 2020.05.17 |
C# paiza 67 - 문자열, 배열도 오브젝트로 (0) | 2020.05.17 |
C# paiza 66 - 억세서를 프로퍼티로 전환 (0) | 2020.05.17 |
글
C# paiza 68 - String 클래스 가진 메소드 사용
// Stringクラスの持つメソッドを使ってみよう
using System;
public class Practice
{
public static void Main()
{
var str = "The apple never falls far from the tree.";
// それぞれのメソッドの結果を1行ずつ出力する
Console.WriteLine(str.ToUpper());
Console.WriteLine(str.Substring(4)); //0부터 시작해서 4번째 문자부터 출력
Console.WriteLine(str.IndexOf("apple"));
}
}
///////////////
'프로그래밍' 카테고리의 다른 글
C# paiza 70 - 오버로드2 (0) | 2020.05.19 |
---|---|
C# paiza 69 - 오버로드1 (0) | 2020.05.19 |
C# paiza 67 - 문자열, 배열도 오브젝트로 (0) | 2020.05.17 |
C# paiza 66 - 억세서를 프로퍼티로 전환 (0) | 2020.05.17 |
C# paiza 65 - 프로퍼티2 (0) | 2020.05.17 |
글
C# paiza 67 - 문자열, 배열도 오브젝트로
// 文字列や配列もオブジェクトになっている
using System;
public class Lesson07
{
public static void Main()
{
var text = "Hello World";
Console.WriteLine(text.Length);
Console.WriteLine(text);
Console.WriteLine(text.ToUpper()); //대문자로 출력하기
}
}
///문자 출력 숫자 조회
//
// 文字列や配列もオブジェクトになっている
using System;
public class Lesson07
{
public static void Main()
{
var text = "Hello World";
Console.WriteLine(text.Length);
Console.WriteLine(text.ToUpper());
Console.WriteLine(text);
int[] numbers = {1,2,3,4};
foreach(var number in numbers)
{
Console.Write(number + " ");
}
}
}
///////
//배열의 요소 출력
//
// 文字列や配列もオブジェクトになっている
using System;
public class Lesson07
{
public static void Main()
{
var text = "Hello World";
Console.WriteLine(text.Length);
Console.WriteLine(text.ToUpper());
Console.WriteLine(text);
int[] numbers = {1,2,3,4};
foreach(var number in numbers)
{
Console.Write(number + " ");
}
Console.WriteLine();
numbers.SetValue(100, 2);
foreach(var number in numbers)
{
Console.Write(number + " ");
}
Console.WriteLine();
Console.WriteLine(numbers.Length);
}
}
/////
//////////
//
'프로그래밍' 카테고리의 다른 글
C# paiza 69 - 오버로드1 (0) | 2020.05.19 |
---|---|
C# paiza 68 - String 클래스 가진 메소드 사용 (0) | 2020.05.17 |
C# paiza 66 - 억세서를 프로퍼티로 전환 (0) | 2020.05.17 |
C# paiza 65 - 프로퍼티2 (0) | 2020.05.17 |
C# paiza 64 - 생성된 오브젝트의 수 세기, 프로퍼티 (0) | 2020.05.17 |
글
C# paiza 66 - 억세서를 프로퍼티로 전환
// アクセッサをプロパティに置き換えよう
using System;
public class Practice
{
public static void Main()
{
var adventurer = new Adventurer("冒険者", 120);
var wizard = new Adventurer("ウィザード", 549);
var crusader = new Adventurer("クルセイダー", 50);
var priest = new Adventurer("プリースト", 480);
Adventurer[] party = {adventurer, wizard, crusader, priest};
foreach (Adventurer player in party)
{
player.Attack();
Console.WriteLine("残りMP" + player.GetMP());
}
Console.WriteLine("冒険者の総人数は" + Adventurer.Count + "人");
}
}
class Adventurer
{
private string job;
private int mp;
private static int count;
public Adventurer(string job, int mp)
{
this.job = job;
this.mp = mp;
Count += 1;
}
public void Attack()
{
Console.WriteLine(job + "は魔王を攻撃した");
mp -= 5;
}
public int GetMP()
{
return mp;
}
// Countプロパティに置き換える
public static int Count { get; private set; }
}
'프로그래밍' 카테고리의 다른 글
C# paiza 68 - String 클래스 가진 메소드 사용 (0) | 2020.05.17 |
---|---|
C# paiza 67 - 문자열, 배열도 오브젝트로 (0) | 2020.05.17 |
C# paiza 65 - 프로퍼티2 (0) | 2020.05.17 |
C# paiza 64 - 생성된 오브젝트의 수 세기, 프로퍼티 (0) | 2020.05.17 |
C# paiza 63 - 억세스 수식자 생략, Static (0) | 2020.05.17 |
글
C# paiza 65 - 프로퍼티2
// プロパティを理解しよう
using System;
public class Lesson07
{
public static void Main()
{
var apple = new Item(120, 15);
var total = apple.GetTotalPrice();
Console.WriteLine("合計金額は" + total + "円です");
var orange = new Item(85, 32);
Console.WriteLine("合計金額は" + orange.GetTotalPrice() + "円です");
//item.Count =0;를 대입하면 0이 된다.
Console.WriteLine("アイテムは" + Item.Count + "種類です");
}
}
// 프로퍼티 요미카키 할 때 사용
public class Item
{
private int price;
private int quantity;
private static int count; //C#에서는 0으로 자동으로 대입되어 있다.
// 관례적으로 프로퍼티의 앞을 대문자로. 소문자로 해도 됨.
public static int Count
{
get
{
return count;
}
set
{
count = value;
}
}
//카운트 프로퍼티가 됐다.
public Item (int price, int quantity)
{
this.price = price;
this.quantity = quantity;
Count += 1;
}
public int GetTotalPrice()
{
return price * quantity;
}
}
////////////
////
// プロパティを理解しよう
using System;
public class Lesson07
{
public static void Main()
{
var apple = new Item(120, 15);
var total = apple.GetTotalPrice();
Console.WriteLine("合計金額は" + total + "円です");
var orange = new Item(85, 32);
Console.WriteLine("合計金額は" + orange.GetTotalPrice() + "円です");
//item.Count =0;를 대입하면 0이 된다.
Console.WriteLine("アイテムは" + Item.Count + "種類です");
}
}
// 프로퍼티 요미카키 할 때 사용
public class Item
{
private int price;
private int quantity;
private static int count; //C#에서는 0으로 자동으로 대입되어 있다.
// 관례적으로 프로퍼티의 앞을 대문자로. 소문자로 해도 됨.
public static int Count
{
get
{
return count;
}
set
{
count = value;
}
}
//카운트 프로퍼티가 됐다.
public Item (int price, int quantity)
{
this.price = price;
this.quantity = quantity;
Count += 1;
}
public int GetTotalPrice()
{
return price * quantity;
}
}
//////////
////
//
// プロパティを理解しよう
using System;
public class Lesson07
{
public static void Main()
{
var apple = new Item(120, 15);
var total = apple.GetTotalPrice();
Console.WriteLine("合計金額は" + total + "円です");
var orange = new Item(85, 32);
Console.WriteLine("合計金額は" + orange.GetTotalPrice() + "円です");
Console.WriteLine("アイテムは" + Item.Count + "種類です");
}
}
// 프로퍼티 요미카키 할 때 사용
public class Item
{
private int price;
private int quantity;
// 관례적으로 프로퍼티의 앞을 대문자로. 소문자로 해도 됨.
public static int Count { get; private set; }
//count 필드가 없어도 작동한다.
public Item (int price, int quantity)
{
this.price = price;
this.quantity = quantity;
Count += 1;
}
public int GetTotalPrice()
{
return price * quantity;
}
}
///////////
'프로그래밍' 카테고리의 다른 글
C# paiza 67 - 문자열, 배열도 오브젝트로 (0) | 2020.05.17 |
---|---|
C# paiza 66 - 억세서를 프로퍼티로 전환 (0) | 2020.05.17 |
C# paiza 64 - 생성된 오브젝트의 수 세기, 프로퍼티 (0) | 2020.05.17 |
C# paiza 63 - 억세스 수식자 생략, Static (0) | 2020.05.17 |
C# paiza 62 - 억세스 수식자 이해하기 (0) | 2020.05.17 |
글
C# paiza 64 - 생성된 오브젝트의 수 세기, 프로퍼티
// 生成されたオブジェクトの数を数えられるようにしよう
using System;
public class Practice
{
public static void Main()
{
var adventurer = new Adventurer("冒険者", 120);
var wizard = new Adventurer("ウィザード", 549);
var crusader = new Adventurer("クルセイダー", 50);
var priest = new Adventurer("プリースト", 480);
Adventurer[] party = {adventurer, wizard, crusader, priest};
foreach (Adventurer player in party)
{
player.Attack();
Console.WriteLine("残りMP" + player.GetMP());
}
Console.WriteLine("冒険者の総人数は" + Adventurer.GetCount() + "人");
}
}
class Adventurer
{
private string job;
private int mp;
// 外部からアクセスできないスタティックな変数を定義する
public static int count=0;
public Adventurer(string job, int mp)
{
this.job = job;
this.mp = mp;
count++;
}
public void Attack()
{
Console.WriteLine(job + "は魔王を攻撃した");
mp -= 5;
}
public int GetMP()
{
return mp;
}
// 冒険者の総人数を返すstaticなメソッドを追加する
public static int GetCount()
{
return count;
}
}
///////////
/////
// プロパティを理解しよう
using System;
public class Lesson07
{
public static void Main()
{
var apple = new Item(120, 15);
var total = apple.GetTotalPrice();
Console.WriteLine("合計金額は" + total + "円です");
var orange = new Item(85, 32);
Console.WriteLine("合計金額は" + orange.GetTotalPrice() + "円です");
Console.WriteLine("アイテムは" + Item.GetCount() + "種類です");
}
}
// 프로퍼티 요미카키 할 때 사용
public class Item
{
private int price;
private int quantity;
private static int count = 0;
// 관례적으로 프로퍼티의 앞을 대문자로. 소문자로 해도 됨.
public static int Count
{
get
{
return count;
}
set
{
count = value;
}
}
//카운트 프로퍼티가 됐다.
public Item (int price, int quantity)
{
this.price = price;
this.quantity = quantity;
count += 1;
}
public int GetTotalPrice()
{
return price * quantity;
}
public static int GetCount()
{
return count;
}
}
/////////
////////////
////
// プロパティを理解しよう
using System;
public class Lesson07
{
public static void Main()
{
var apple = new Item(120, 15);
var total = apple.GetTotalPrice();
Console.WriteLine("合計金額は" + total + "円です");
var orange = new Item(85, 32);
Console.WriteLine("合計金額は" + orange.GetTotalPrice() + "円です");
Console.WriteLine("アイテムは" + Item.GetCount() + "種類です");
}
}
// 프로퍼티 요미카키 할 때 사용
public class Item
{
private int price;
private int quantity;
private static int count = 0;
// 관례적으로 프로퍼티의 앞을 대문자로. 소문자로 해도 됨.
public static int Count
{
get
{
return count;
}
set
{
count = value;
}
}
//카운트 프로퍼티가 됐다.
public Item (int price, int quantity)
{
this.price = price;
this.quantity = quantity;
count += 1;
}
public int GetTotalPrice()
{
return price * quantity;
}
public static int GetCount()
{
return count;
}
}
/////////
'프로그래밍' 카테고리의 다른 글
C# paiza 66 - 억세서를 프로퍼티로 전환 (0) | 2020.05.17 |
---|---|
C# paiza 65 - 프로퍼티2 (0) | 2020.05.17 |
C# paiza 63 - 억세스 수식자 생략, Static (0) | 2020.05.17 |
C# paiza 62 - 억세스 수식자 이해하기 (0) | 2020.05.17 |
C# paiza 61 - 사과 금액 구하기 (0) | 2020.05.17 |
글
C# paiza 63 - 억세스 수식자 생략, Static
// アクセス修飾子を省略しよう
using System;
public class Lesson07
{
public static void Main()
{
var player = new Player("勇者");
player.Walk();
Console.WriteLine(player.name);
}
}
public class Player
{
public string name;
// 필드의 억세스 수식자를 생략하면 private가 된다.
//string name;
public Player(string name)
{
this.name = name;
}
public void Walk()
{
Console.WriteLine (name + "は荒野を歩いていた");
}
// 메소드에서 억세스 수식자를 생략하면 private가 된다.
}
//////////////
// 필드, 콘스트럭터, 메소드에서 억세스 수식자를 생략하면 다 private가 된다.
// 인터널 억세스 수식자
// 그 안에서 사용할 수 있는 수식자
// 개발할 때 사용한다.
//
// staticを理解しよう
using System;
public class Lesson07
{
public static void Main()
{
var apple = new Item(120, 15); //오브젝트 작성
//카운트가 0에서 1이 된다.
var total = apple.GetTotalPrice();
Console.WriteLine("合計金額は" + total + "円です");
var orange = new Item(85, 32); // 두 번째 오브젝트 작성
//카운트가 1에서 2로 변환
Console.WriteLine("合計金額は" + orange.GetTotalPrice() + "円です");
Console.WriteLine("商品は" + Item.GetCount() + "種類です。");
}
}
public class Item
{
private int price;
private int quantity;
public static int count=0;
//static이라고 하면 실행이 가능하다. 불러올 수 있네
//static 앞에 클래스의 종류 private나 public을 입력
public Item(int price, int quantity)
{
this.price = price;
this.quantity = quantity;
count++;
}
public int GetTotalPrice()
{
return price * quantity;
}
public static int GetCount()
{
return count;
}
}
/////////////
static을 이해하자
////
'프로그래밍' 카테고리의 다른 글
C# paiza 65 - 프로퍼티2 (0) | 2020.05.17 |
---|---|
C# paiza 64 - 생성된 오브젝트의 수 세기, 프로퍼티 (0) | 2020.05.17 |
C# paiza 62 - 억세스 수식자 이해하기 (0) | 2020.05.17 |
C# paiza 61 - 사과 금액 구하기 (0) | 2020.05.17 |
C# paiza 60 - RPG 클래스 출력2 (0) | 2020.05.17 |