Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need help with Fundamentals Lab 13 exercise 3.2 code in this exercise. Code: Exercise 13-1 Creating Classes Weather forecast using classes

Need help with Fundamentals Lab 13 exercise 3.2 code in this exercise.

Code:

Exercise 13-1 Creating Classes

Weather forecast using classes

ini_set("display_errors",1); date_default_timezone_set('EST'); include_once("Forecast.class.php");

$today = time(); $oneday = 60*60*24;

$dayOne = new Forecast (date("d M, Y", $today),30,20,"sunny"), new Forecast (date("d M, Y", $today+$oneday),35, 22, "clear and sunnny"), new Forecast (date("d M, Y", $today+2*$oneday),20, 10, "cold and snow"), new Forecast (date("d M, Y", $today+3*$oneday),25, 14, "chilly"), new Forecast (date("d M, Y", $today+4*$oneday),30, 24, "sunny"), new Forecast (date("d M, Y", $today+5*$oneday),40, 26, "warming"), new Forecast (date("d M, Y", $today+6*$oneday),50, 34, "hot") );

foreach($forecast as $oneDay){ echo $oneDay; }

?>

Instructions:

image text in transcribed

In the previous exercise you wrote a constructor, but the instantiation of the Forecase objects was already done for you. This exercise will walk you through calling your own constructors. Continue working on the previous Exercise for this Exercise. Find the code that defines that array for Forecast objects and remove it. Now we will walk through instantiating objects, and adding them to an array manually. Add the following code to define a single Forecast Object and output it. \$dayOne = new Forecast ( date("d M, Y", \$today), 30, 20, "sunny"); echo \$dayOne; Now bring up a local forecast for your city. Forecast information is widely available on the WWW. Instantiate 7 forecast objects to represent the next 7 days forecast. Add each of the Forecast objects to the array named forecast as follows: \$forecast = array (); \$forecast [] = \$dayone; //assuming \$dayOne defines as above. Your output will now look similar to the output from Exercise 1, but will be relevant to your city, and make use of instantiated objects of type Forecast

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing Fundamentals Design And Implementation

Authors: David M. Kroenke

5th Edition

B000CSIH5A, 978-0023668814

More Books

Students also viewed these Databases questions