no message
This commit is contained in:
22
Question16-Exception/Ex04.php
Normal file
22
Question16-Exception/Ex04.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* [Ex04 カスタム例外の利用 - CSVファイル処理]
|
||||
*
|
||||
* 難易度:中級
|
||||
*
|
||||
* TODO:
|
||||
* 1. 以下の仕様に従って、カスタム例外クラスを作成してください。
|
||||
* (1) FileNotFoundException クラスを作成し、Exception を継承する。
|
||||
* (2) CSVFormatException クラスを作成し、Exception を継承する。
|
||||
*
|
||||
* 2. 関数 processCSV($filename) を作成してください。
|
||||
* - $filename が "data.csv" でない場合は、FileNotFoundException を投げる。
|
||||
* - $filename が "data.csv" の場合、仮のCSVデータ(例: "John,25,Engineer\nAlice,30,Designer")を用い、
|
||||
* 各行がカンマで区切られているかをチェックし、問題があれば CSVFormatException を投げる。
|
||||
* - 正常な場合は、各行を配列に変換して返す。
|
||||
*
|
||||
* 3. メイン部分で、processCSV() を呼び出し、try-catch ブロックで例外を捕捉し、適切なエラーメッセージを出力してください。
|
||||
*
|
||||
*
|
||||
*/
|
||||
Reference in New Issue
Block a user