Modify the code on part-1.php, as indicated below. a. Create the additional properties for the class Customer: i. address ii. telephone b. Set an appropriate value for each of the newly created property, address and telephone, in the customer object c. Set an appropriate value for forename and surname in the customer object. d. Display the customer’s forename and surname before their email. Both forename and surname should be on the same line e. Display the customer’s address on its own line, after their email. Capture your output with a screenshot f. Use the withdraw method to withdraw $100 for an object of the class, Account g. Update your code to display the new balance. Capture your output with a screenshot
Modify the code on part-1.php, as indicated below.
a. Create the additional properties for the class Customer:
i. address
ii. telephone
b. Set an appropriate value for each of the newly created property, address and telephone,
in the customer object
c. Set an appropriate value for forename and surname in the customer object.
d. Display the customer’s forename and surname before their email. Both forename and
surname should be on the same line
e. Display the customer’s address on its own line, after their email. Capture your output
with a screenshot
f. Use the withdraw method to withdraw $100 for an object of the class, Account
g. Update your code to display the new balance. Capture your output with a screenshot
------
<?php
class Customer//This comment is used to indicate that the a class called 'Customer' is being created
{
public string $forename;
public string $surname;
public string $email;
public string $password;
}
class Account //This a class named, Account
{
public int $number;
public string $type;
public float $balance;
}
public function withdraw(float $amount): float
{
$this->balance -= $amount;
return $this->balance;
}
$customer = new Customer();//An instance of 'customer' class is created using the 'new' operator
$account = new Account(); //same is done with the 'Account' class
$customer->email = 'ivy@eg.link'; //Here, the email property of the customer object is given a value
$account->balance = 1000.00;// The account property of the customer object is given a value
?>
<?php include 'includes/header.php';//This includes the file name header.php ?>
<p>Email: <?= $customer->email ?></p>
<p>Balance: $<?= $account->balance ?></p>
<?php include 'includes/footer.php';//This includes the file name footer.php ?>
Step by step
Solved in 3 steps with 2 images