Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2017
360
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.44 KB | None | 0 0
  1. <?php
  2. require_once ('class_students.php');
  3. require_once ('class_dates.php');
  4. require_once ('class_phone.php');
  5. require_once ('class_address.php');
  6.  
  7.  
  8. class Locals extends Students{
  9.  
  10. private $proofOfEnglish;
  11. private $IDType;
  12. private $IDNumber;
  13. private $registrationFee;
  14. private $programName;
  15. private $programTuition;
  16. private $startDate;
  17.  
  18.  
  19. public function __construct($valueStudentName, $valueStudentSurname, $valueStudentEmail, $valueDateOfBirth,
  20. $valueStudentPhone, $valueStudentCellphone, $valueStudentAddress, $valueProofOfEnglish, $valueIDType, $valueIDNumber, $valueProgramName,
  21. $valueStartDate, $valueRegistrationFee, $valueProgramTuition){
  22. $this->set_studentName($valueStudentName);
  23. $this->set_studentSurname($valueStudentSurname);
  24. $this->set_studentEmail($valueStudentEmail);
  25. $this->set_studentPhone($valueStudentPhone);
  26. $this->set_studentCellphone($valueStudentCellphone);
  27. $this->set_studentAddress($valueStudentAddress);
  28. $this->set_studentDateOfBirth($valueDateOfBirth);
  29. $this->set_proofOfEnglish($valueProofOfEnglish);
  30. $this->set_IDType($valueIDType);
  31. $this->set_IDNumber($valueIDNumber);
  32. $this->set_registrationFee($valueRegistrationFee);
  33. $this->set_programName($valueProgramName);
  34. $this->set_programTuition($valueProgramTuition);
  35. $this->set_startDate($valueStartDate);
  36.  
  37. }
  38.  
  39. //If there is not at least one '' in the new_studentAddress, it will return a format error.
  40. //When we use the explode, we create an array to $address with $new_studentAddress data
  41. //with this format: Canada, BC, Vancouver, 1236, 7895, Howe St
  42. public function set_studentAddress($new_studentAddress){
  43. if (strpos($new_studentAddress, ',') === false) {
  44. throw new Exception("You need to pass the address as: Canada, BC, Vancouver, 1236, 7895, Howe St");
  45. }
  46.  
  47. $address = explode(",", $new_studentAddress);
  48.  
  49. $this->studentAddress = new Address($address[0], $address[1], $address[2], $address[3], $address[4], $address[5]);
  50. //When I create new Address, my var $studentAddress receives the values from class Address
  51. }
  52.  
  53. //If there is not at least one '' in the new_studentCellphone, it will return a format error.
  54. //When we use the explode, we create an array to $cellphone with $new_studentCellphone data with this format: 1 657 7894559 12
  55. public function set_studentCellphone($new_studentCellphone){
  56. if (strpos($new_studentCellphone, ' ') === false) {
  57. throw new Exception("You need to pass the cellphone as: 1 657 7894559");
  58. }
  59.  
  60. $cellphone = explode(" ", $new_studentCellphone);
  61.  
  62. //this condition checks if the phone number has an extension number or not.
  63. //if there is not an extension number, the last item is null.
  64. if (count($cellphone)==4){
  65. $extensionNumber = $cellphone[3];
  66. }else{
  67. $extensionNumber = null;
  68. }
  69.  
  70. $this->studentCellphone = new Phone($cellphone[0], $cellphone[1], $cellphone[2], $extensionNumber);
  71. //When I create new Dates, my var $studentCellphone receives the values from class Phone
  72. }
  73.  
  74.  
  75. //If there is not at least one '' in the new_studentPhone, it will return a format error.
  76. //When we use the explode, we create an array to $phone with $new_studentPhone data with this format: 1 657 7894559 12
  77. public function set_studentPhone($new_studentPhone){
  78. if (strpos($new_studentPhone, ' ') === false) {
  79. throw new Exception("You need to pass the phone as: 1 657 7894559 12(if there is an extension)");
  80. }
  81.  
  82. $phone = explode(" ", $new_studentPhone);
  83.  
  84. //this condition checks if the phone number has an extension number or not.
  85. //if there is not an extension number, the last item is null.
  86. if (count($phone)==4){
  87. $extensionNumber = $phone[3];
  88. }else{
  89. $extensionNumber = null;
  90. }
  91.  
  92. $this->studentPhone = new Phone($phone[0], $phone[1], $phone[2], $extensionNumber);
  93. /* When I create new Phone, my var $studentPhone receives the values from class Phone*/
  94. }
  95.  
  96. //If there is not at least one / in the new_dateOfBirth, it will return a format error.
  97. //When we use the explode, we create an array to $studentDateOfBirth with $new_dateOfBirth data with this format: 21/01/2017
  98. public function set_studentDateOfBirth($new_dateOfBirth){
  99. if (strpos($new_dateOfBirth, '/') === false) {
  100. throw new Exception("You need to pass the date as: 25/01/2017");
  101. }
  102.  
  103. $studentDateOfBirth = explode("/", $new_dateOfBirth);
  104. $this->dateOfBirth = new Dates($studentDateOfBirth[0], $studentDateOfBirth[1], $studentDateOfBirth[2]);
  105. /* When I create new Dates, my var $studentDateOfBirth receives the values from class Dates*/
  106. }
  107.  
  108. public function set_studentName($new_studentName){
  109. if(!isset($new_studentName)){
  110. throw new Exception("The student name field cannot be empty.");
  111. }
  112. if(strlen($new_studentName) > 20){
  113. throw new Exception("The student name cannot be greater than 20 characteres.");
  114. }
  115. $this->studentName = $new_studentName;
  116. }
  117.  
  118. public function set_studentSurname($new_studentSurname){
  119. if(!isset($new_studentSurname)){
  120. throw new Exception("The student surname field cannot be empty.");
  121. }
  122. if(strlen($new_studentSurname) > 50){
  123. throw new Exception("The student surname cannot be greater than 50 characteres.");
  124. }
  125. $this->studentSurname = $new_studentSurname;
  126. }
  127.  
  128. public function set_studentEmail($new_studentEmail){
  129. if(!isset($new_studentEmail)){
  130. throw new Exception("The student email field cannot be empty.");
  131. }
  132. if(strlen($new_studentEmail) > 50){
  133. throw new Exception("The student email cannot be greater than 50 characteres.");
  134. }
  135. $this->studentEmail = $new_studentEmail;
  136. }
  137.  
  138. public function set_proofOfEnglish($new_proofOfEnglish){
  139. if(!isset($new_proofOfEnglish)){
  140. throw new Exception("The proof of English field cannot be empty.");
  141. }
  142. if(strlen($new_proofOfEnglish) > 15){
  143. throw new Exception("The proof of English cannot be greater than 15 characteres.");
  144. }
  145. $this->proofOfEnglish = $new_proofOfEnglish;
  146. }
  147.  
  148. public function set_IDType($new_IDType){
  149. if(!isset($new_IDType)){
  150. throw new Exception("The ID Type field cannot be empty.");
  151. }
  152. if(strlen($new_IDType) > 30){
  153. throw new Exception("The ID type cannot be greater than 30 characteres.");
  154. }
  155. $this->IDType= $new_IDType;
  156. }
  157.  
  158. public function set_IDNumber($new_IDNumber){
  159. if(!isset($new_IDNumber)){
  160. throw new Exception("The ID Number field cannot be empty.");
  161. }
  162. if(!is_numeric($new_IDNumber)){
  163. throw new Exception("The ID number must be a number.");
  164. }
  165. if(strlen($new_IDNumber) > 10){
  166. throw new Exception("The ID number cannot be greater than 10 characteres.");
  167. }
  168. $this->IDNumber = $new_IDNumber;
  169. }
  170.  
  171. public function set_programName($new_programName){
  172. if(!isset($new_programName)){
  173. throw new Exception("The program name field cannot be empty.");
  174. }
  175.  
  176. if(strlen($new_programName) > 25){
  177. throw new Exception("The program name cannot be greater than 25 characteres.");
  178. }
  179. $this->programName = $new_programName;
  180. }
  181.  
  182. public function set_programTuition($new_programTuition){
  183. if(!isset($new_programTuition)){
  184. throw new Exception("The program tuition field cannot be empty.");
  185. }
  186. if(!is_numeric($new_programTuition)){
  187. throw new Exception("The program tuition must be a number.");
  188. }
  189. if(strlen($new_programTuition) > 10){
  190. throw new Exception("The program tuition cannot be greater than 10 characteres.");
  191. }
  192. $this->programTuition = $new_programTuition;
  193. }
  194.  
  195. public function set_registrationFee($new_registrationFee){
  196. if(!isset($new_registrationFee)){
  197. throw new Exception("The registration fee field cannot be empty.");
  198. }
  199. if(!is_numeric($new_registrationFee)){
  200. throw new Exception("The registration fee must be a number.");
  201. }
  202. if(strlen($new_registrationFee) > 10){
  203. throw new Exception("The registration fee cannot be greater than 10 characteres.");
  204. }
  205. $this->registrationFee = $new_registrationFee;
  206. }
  207.  
  208. //If there is not at least one / in the new_start date, it will return a format error.
  209. //When we use the explode, we create an array to dateStart with $new_startDate data with this format: 21/01/2017
  210. public function set_startDate($new_startDate){
  211. if (strpos($new_startDate, '/') === false) {
  212. throw new Exception("You need to pass the date as: 25/01/2017");
  213. }
  214.  
  215. $dateStart = explode("/", $new_startDate);
  216. $this->startDate = new Dates($dateStart[0], $dateStart[1], $dateStart[2]);
  217. /* When I create new Dates, my var dateStart receives the values from class Dates*/
  218. }
  219.  
  220. public function get_studentName(){
  221. return $this->studentName;
  222. }
  223.  
  224. public function get_studentSurname(){
  225. return $this->studentSurname;
  226. }
  227.  
  228. public function get_studentEmail(){
  229. return $this->studentEmail;
  230. }
  231.  
  232. public function get_dateOfBirth(){
  233. return $this->dateOfBirth;
  234. }
  235.  
  236. public function get_studentPhone(){
  237. return $this->studentPhone;
  238. }
  239.  
  240. public function get_studentCellphone(){
  241. return $this->studentCellphone;
  242. }
  243. public function get_studentAddress(){
  244. return $this->studentAddress;
  245. }
  246.  
  247. public function get_ProofOfEnglish(){
  248. return $this->proofOfEnglish;
  249. }
  250.  
  251. public function get_IDType(){
  252. return $this->IDType;
  253. }
  254.  
  255. public function get_IDNumber(){
  256. return $this->IDNumber;
  257. }
  258.  
  259. public function get_programName(){
  260. return $this->programName;
  261. }
  262.  
  263. public function get_programTuition(){
  264. return $this->programTuition;
  265. }
  266.  
  267. public function get_registrationFee(){
  268. return $this->registrationFee;
  269. }
  270.  
  271. public function get_startDateDMY(){
  272. return $this->startDate->printDateDMY();
  273. }
  274.  
  275. public function get_startDateMDYThreeMonthsAhead(){
  276. return $this->startDate->printDateDMYThreeMonthsAhead();
  277. }
  278.  
  279. public function get_startDateMDYSixMonthsAhead(){
  280. return $this->startDate->printDateDMYSixMonthsAhead();
  281. }
  282.  
  283. public function get_startDateMDYNineMonthsAhead(){
  284. return $this->startDate->printDateDMYNineMonthsAhead();
  285. }
  286.  
  287. public function payment(){
  288. echo "<br />Local Student paying...<br/><br/>";
  289. }
  290.  
  291. }
  292.  
  293.  
  294. // try{
  295.  
  296.  
  297.  
  298. // $local = new Locals('Anne', 'Thompson', 'annt@gmail.com', '14/07/1991', '1 657 7894559 12', '1 704 7894559', 'Canada, BC, Vancouver, 1236, 7895, Howe St',
  299. // 'IELTS', 'Local', 111, 'Web Development','21/01/2017', 1000, 4500);
  300.  
  301. // echo "<pre>";
  302. // print_r($local);
  303. // echo "</pre>";
  304. // //echo $local->get_startDateDMY()."<br/>";
  305. // //echo $local->payment();
  306.  
  307. // } catch (Exception $exception) {
  308. // echo "<br/>";
  309. // echo '<span style="color:red;">Caught exception: ', $exception->getMessage(), '</span>';
  310. // }
  311.  
  312. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement