PHP Classes

File: Falcraft/examples/Data/Types/Range.php

Recommend this page to a friend!
  Classes of Asher Wolfstein   Abstract Data Types   Falcraft/examples/Data/Types/Range.php   Download  
File: Falcraft/examples/Data/Types/Range.php
Role: Example script
Content type: text/plain
Description: Range Example
Class: Abstract Data Types
Set of abstract data types as pure PHP classes
Author: By
Last change:
Date: 9 years ago
Size: 2,491 bytes
 

Contents

Class file image Download
<?php

require_once('../../../Data/Types/Range.php');

use
Falcraft\Data\Types;

echo
"Falcraft\\Data\\Types\\Range.php Test\n";
echo
"----------------------------------\n\n";

echo
"Basic Instantiation -> ";

$success = true;

$testRange0 = $testRange1= null;

try {
   
$testRange0 = new Types\Range();
   
$testRange1 = new Types\Range(3, 3);
} catch (\
Exception $e) {
   
$success = false;
}

if (
$success) {
    echo
"Success!\n";
} else {
    echo
"Failure...\n";
}

echo
"Improper Instantiation -> ";

$fail = true;

$testRange2 = null;

try {
   
$testRange2 = new Types\Range(2, 5);
   
$fail = false;
} catch (\
Exception $e) {
   
}

if (
$fail) {
    echo
"Failure!\n";
} else {
    echo
"Success...\n";
}

echo
"Set Maximum (7) -> ";

$success = true;

$val = null;

try {
   
$testRange0->setMaximum(7);
   
$val = $testRange0->getMaximum();
} catch (\
Exception $e) {
   
$success = false;
}

if (
$success) {
    echo
"Success!\n";
} else {
    echo
"Failure...\n";
}

echo
"Set Minimum (1) -> ";

$success = true;

$val = null;

try {
   
$testRange0->setMinimum(1);
   
$val = $testRange0->getMinimum();
} catch (\
Exception $e) {
   
$success = false;
}

if (
$success) {
    echo
"Success!\n";
} else {
    echo
"Failure...\n";
}

echo
"Is In Range (3) -> ";

try {
    if (
$testRange0->isInRange(3)) {
        echo
"Yes\n";
    } else {
        echo
"No\n";
    }
} catch (\
Exception $e) {
    echo
"EXCEPTION CAUGHT\n";
}

echo
"Is In Range (8) -> ";

try {
    if (
$testRange0->isInRange(8)) {
        echo
"Yes\n";
    } else {
        echo
"No\n";
    }
} catch (\
Exception $e) {
    echo
"EXCEPTION CAUGHT\n";
}

echo
"Is In Range (7) -> ";

try {
    if (
$testRange0->isInRange(7)) {
        echo
"Yes\n";
    } else {
        echo
"No\n";
    }
} catch (\
Exception $e) {
    echo
"EXCEPTION CAUGHT\n";
}

echo
"Is In Range (7) maximum = true -> ";

try {
    if (
$testRange0->isInRange(7, array('maximum' => true))) {
        echo
"Yes\n";
    } else {
        echo
"No\n";
    }
} catch (\
Exception $e) {
    echo
"EXCEPTION CAUGHT\n";
}

echo
"Is In Range (1) -> ";

try {
    if (
$testRange0->isInRange(1)) {
        echo
"Yes\n";
    } else {
        echo
"No\n";
    }
} catch (\
Exception $e) {
    echo
"EXCEPTION CAUGHT\n";
}

echo
"Is In Range (1) minimum = true -> ";

try {
    if (
$testRange0->isInRange(1, array('minimum' => true))) {
        echo
"Yes\n";
    } else {
        echo
"No\n";
    }
} catch (\
Exception $e) {
    echo
"EXCEPTION CAUGHT\n";
}