This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
defined('BASEPATH') OR exit('No direct script access allowed'); | |
class Guesses extends CI_Model { | |
private $names = array('Taylor Swift',"Lionel Messi","Dwayne Johnson","Brad Pitt","Rihanna"); | |
// the images must be in the same order as the names | |
private $imageurls | |
= array( | |
'https://www.gannett-cdn.com/presto/2019/09/17/USAT/70408641-17f0-4a80-8f7c-596abf9da9a8-AP_People-Taylor_Swifts_House.JPG?width=540&height=&fit=bounds&auto=webp', | |
'https://pmcwwd.files.wordpress.com/2019/05/messi-1.jpg?w=640&h=415&crop=1', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"> | |
</head> | |
<body style="padding:20px"> | |
<div> | |
<!-- | |
Display the image using the image url sent back by the model. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<?php | |
// we don't always want to display the right name and wrong | |
// name in the same order, so randomly mix them up | |
$choice = rand(0,1); | |
if ($choice == 1) { | |
// display correct name last | |
$name1 = $wrongname; | |
$name2 = $name; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
defined('BASEPATH') OR exit('No direct script access allowed'); | |
class Guesser extends CI_Controller { | |
function __construct() | |
{ | |
// call base class constructor | |
parent::__construct(); | |
// Load the guesses model. This will create a new | |
// attribute object in the controller called 'guesses', which |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
class Price { | |
int pounds; | |
int pence; | |
public: | |
Price(float f) { | |
pounds = static_cast<int>(f); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
struct Student { | |
std::string name; | |
int grade; | |
}; | |
/* | |
Calculate average grade for an array of students |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <fstream> | |
#include <sstream> | |
int main() | |
{ | |
// create an ifstream object to read the file | |
// Note this file is in the same directory as the code since the | |
// filename doesn't contain any directory information | |
std::ifstream in("data.txt"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
struct Student { | |
std::string name; | |
int grade; | |
}; | |
/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
struct Student { | |
std::string name; | |
int grade; | |
}; | |
int main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
int main() | |
{ | |
std::string progName = "Grade Analysis"; | |
std::cout << "Welcome to the " << progName << " program\n" | |
<< "How many students to be entered (max 10)? " << std::endl; | |
NewerOlder