Skip to content

Instantly share code, notes, and snippets.

View rotelstift's full-sized avatar

Kazue Urabe rotelstift

View GitHub Profile
<?php
$numbers = range(0, 9);
// 0を除いた偶数だけ欲しい
$evenNumbers = array_filter(
// https://www.php.net/manual/ja/function.array-filter.php
// 上記の例2を参照
array_filter($numbers),
fn($n) => $n % 2 === 0
);
@rotelstift
rotelstift / Main.java
Created January 28, 2023 02:13
良いコード/悪いコードで学ぶ設計入門を読み終わってから https://gist.github.com/rotelstift/33cdbb8b24948534ba573b2d7f007378 をリファクタリングしたコード
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
public class Main {
/**
* あるお店にかけられた問い合わせ電話の応対をシミュレートするコード
*
* 客からの電話にまず店員が出て質問内容を聞いて答える。
* もし自分では答えられない内容だったら店長に取り次ぐ。
@rotelstift
rotelstift / Main.java
Last active January 28, 2023 02:11
良いコード/悪いコードで学ぶ設計入門を読み終えたらリファクタリングする予定のコード
import java.util.Random;
public class Main{
/**
* あるお店にかけられた問い合わせ電話の応対をシミュレートするコード
*
* 客からの電話にまず店員が出て質問内容を聞いて答える。
* もし自分では答えられない内容だったら店長に取り次ぐ。
*
* しかし、店長が忙しくて電話に出られない時は、
@rotelstift
rotelstift / thinkingAbout_8_2_good_pattern.java
Created January 11, 2023 00:45
良いコード/悪いコードで学ぶ設計入門を読んで書いたコード
class Main {
public static void main(String[] args) {
final FighterPhysicalAttack fighterPhysicalAttack = new FighterPhysicalAttack(50);
System.out.println(fighterPhysicalAttack.singleAttackDamage());
System.out.println(fighterPhysicalAttack.doubleAttackDamage());
}
}
class PhysicalAttack {
@rotelstift
rotelstift / thinkingAbout_8_2_bad_pattarn.java
Created January 11, 2023 00:43
良いコード/悪いコードで学ぶ設計入門を読んで書いたコード
class Main {
public static void main(String[] args) {
final FighterPhysicalAttack fighterPhysicalAttack = new FighterPhysicalAttack(50);
System.out.println(fighterPhysicalAttack.singleAttackDamage());
System.out.println(fighterPhysicalAttack.doubleAttackDamage());
}
}
class PhysicalAttack {
@rotelstift
rotelstift / thinkingAbout_6_3.java
Created January 8, 2023 10:12
良いコード/悪いコードで学ぶ設計入門を読んで書いたコード
import java.util.HashMap;
import java.util.Map;
import java.util.HashSet;
import java.util.Set;
class Main {
public static void main(String[] args) {
final Customer customerA = new Customer("ID-0001");
final Customer customerB = new Customer("ID-0002");
final Customer customerC = new Customer("ID-0003");
@rotelstift
rotelstift / thinkingAbout_6_2.java
Created January 8, 2023 08:21
良いコード/悪いコードで学ぶ設計入門を見ながら書いたコード
import java.util.HashMap;
import java.util.Map;
class Main {
static final Map<MagicType, Magic> magics = new HashMap<>();
public static void main(String[] args) {
final Caster caster = new Caster("アルトリア", 90);
final Fire fire = new Fire(caster);
final Thunder thunder = new Thunder(caster);
final HellFire hellFire = new HellFire(caster);
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
<style>
td{
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
<style>
td{
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Random;
public class CallingMethod{
public static void main(String[] args){
//電話、メンバー、スタッフのインスタンスを作る
Telephone phone = new Telephone();
Member urabe = new Member("卜部");
Staff otsuka = new Staff("大塚");