100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
Summary ict3612 assignment 2 $11.73   Add to cart

Summary

Summary ict3612 assignment 2

 34 views  1 purchase
  • Course
  • Institution

This document is a comprehensive solution for ICT3612 Assignment 2, focusing on Advanced Internet Programming. It encompasses detailed answers and explanations that cover all aspects of the assignment requirements. Key components include: Coding Solutions: Well-commented code snippets that demon...

[Show more]

Preview 2 out of 7  pages

  • June 2, 2024
  • 7
  • 2023/2024
  • Summary
avatar-seller
Disclaimer



When purchasing this document, please ensure that it aligns with your assignment specifications and
requirements. This document is intended to serve as a reference or guide. It is crucial to thoroughly
review and customize the content to meet the unique criteria of your assignment. Failure to do so may
result in academic consequences. Use this document responsibly and in accordance with your
institution's academic integrity policies.


ict3612

QUESTION 1


<?php
//WRITE THE FUNCTION BELOW AS PER THE QUESTION. NO CODE TO INVOKE THE FUNCTION SHOULD
BE INCLUDED HERE
//NO HTML ALLOWED. ONLY PHP CODE IS ALLOWED

function processNumbers(...$args) {
$maxNumber = null;

foreach ($args as $arg) {
if (is_numeric($arg)) {
if ($maxNumber === null || $arg > $maxNumber) {
$maxNumber = $arg;
}
}
}

return $maxNumber;
}

?>

QUESTION 2

<?php
$stdin = fopen("php://stdin", "r"); //DO NOT CHANGE THIS LINE
$input_number = (int)fgets($stdin); //DO NOT CHANGE THIS LINE, $input_number will store the number
(1 to 3)
$input_string = trim(fgets($stdin)); //DO NOT CHANGE THIS LINE, $input_string will store the input string

// Function mappings
$functions = [
1 => 'strlen',

, 2 => 'strrev',
3 => 'ucwords'
];

// Check if the input number is within the valid range
if (isset($functions[$input_number])) {
$function = $functions[$input_number];
$output_string = $function($input_string);
} else {
$output_string = "Invalid input number";
}

echo $output_string; //DO NOT CHANGE THIS LINE, $output_string must store the output (changed
string)

?>

QUESTION 3

<?php
//WRITE THE CLASS AS PER THE QUESTION.
//NO HTML ALLOWED. ONLY PHP CODE IS ALLOWED

class MotorVehicle {
private $licenseNumber;
private $make;
private $series;

// Constructor to initialize the properties
public function __construct($licenseNumber, $make, $series) {
$this->licenseNumber = $licenseNumber;
$this->make = $make;
$this->series = $series;
}

// Method to return the string representation of the object
public function __toString() {
return "License Number: $this->licenseNumber, Make: $this->make, Series: $this->series";
}

// Static method to compare the make of two MotorVehicle objects
public static function compareMakes($vehicle1, $vehicle2) {
return $vehicle1->make === $vehicle2->make ? "Yes" : "No";
}
}

//CODE TO TEST THE CLASS, DO NOT CHANGE IT
$mv1 = new MotorVehicle("BGS954GP", "Toyota", "Corolla");

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying these notes from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller phegelelo. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for $11.73. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

79064 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy study notes for 14 years now

Start selling
$11.73  1x  sold
  • (0)
  Add to cart