Last active
August 27, 2021 15:32
-
-
Save rikuTanide/e9d9761234b14c0210e6ebf76b858187 to your computer and use it in GitHub Desktop.
途中でReturnしないIF文
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Buyability isBuyable(request) { | |
var result = new Buyability(); | |
// ログインしているか | |
if (isLoggedIn(request)) { | |
// 在庫があるか | |
if (hasStock(request)) { | |
// お金は足りているか | |
if (hasMoney(request)) { | |
result.buyable = true; | |
} else { | |
result.buyalbe = false; | |
result.reason = "money"; | |
} | |
} else { | |
// 再入荷可能か | |
if (canRestocked(request)) { | |
// お金は足りているか | |
if (hasMoney(request)) { | |
result.buyable = true; | |
} else { | |
result.buyable = false; | |
result.reason = "money"; | |
} | |
} else { | |
result.buyable = false; | |
result.reason = "stock"; | |
} | |
} | |
} else { | |
result.buyable = false; | |
result.reason = "login"; | |
} | |
return result; | |
} | |
class Buyability { | |
bool buyable; | |
String reason; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment