brownpaperbag88 Posted August 25, 2015 Share Posted August 25, 2015 Hello everyone, I have this OO Php test I have to do at Uni, I understand the principles of PHP, but I am not sure which classes to use for this task and how to structure it. Also, I cannot use a database, so where can I store the data for the family members? Please see attached file. Any help getting started with this would be much appreciated. Many thanks. mytest.pdf Quote Link to comment Share on other sites More sharing options...
Psycho Posted August 25, 2015 Share Posted August 25, 2015 Regarding the data, it doesn't state if the data needs to persist across sessions. You could just create an associative array (or arrays) with the starting state of all the data. Then on the first page load check to see if that data exists in the session. If not, load the initial data. Then on each subsequent page load use the session data. Then, whatever functionality you have will manipulate the session data. If you closed your browser and go back, you would start with the initial seed data. This is a good approach for an activity such as this for several reasons. You can create specific use cases that start with the initial data. As you test, if a problem is found you can modify the code and start the user cases over from the beginning. If you were to use a database you would likely need to reset it to default data anyway. As for the classes to you - that is up to you. How it should ideally be set up for this exercise would likely be predicated on any lessons you've already had in the class as lessons are typically designed to build upon the previous lessons. Quote Link to comment Share on other sites More sharing options...
brownpaperbag88 Posted August 25, 2015 Author Share Posted August 25, 2015 Thanks for your reply. Can I have an index.php file, generate some data at the top in an assoc array, and the create the $api object and parse the data into $api->getHeritageByName()? Also, could you perhaps tell me how YOU would structure the classes? I am super lost with it. Many thanks. Quote Link to comment Share on other sites More sharing options...
Psycho Posted August 25, 2015 Share Posted August 25, 2015 I would create an index.php file that is used for all the requests. That file would have something like this at the top session_start(); //Check if family data is already set in session if(!isset($_SESSION['family'])) { //Set the default data include('setDefaultData.php'); } The setDefaultData.php page would have the initial data to set in the session. Something like this $family = array( //Include all the associative array data to set for the default ); $_SESSION['family'] = $family; As for how I would do it, I am the wrong person to ask. I don't have a formal education in programming and your instructor is looking for the use of specific design patterns. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.