Wow! That you so much! That is exactly the kind of thing I was looking for! Thank youuuuuu!
redhotspike 0 Newbie Poster
22 Hours Ago | Add to redhotspike's Reputation | Flag Bad Post
I have never used PHP before. I'm pretty hardcore with (x)HTML, JavaScript, CSS, and I also know C++.
Here's the thing - I need to create some sort of code that receives information from the back end of a site and dynamically adds a link on an overview page of that new article and also creates a new webpage with the article on it.
I'm not quite sure where to start or how to go about doing this. If anyone could give me a push in how to get started or maybe explain how the code would work?
**The link will reside on a page built with HTML**
Any help is greatly appreciated....
If necessary I'll use ASP (but I don't have any experience with that either )
Thanks!
redhotspike 0 Newbie Poster
Ok - I have never used ASP before. I'm pretty hardcore with (x)HTML, JavaScript, CSS, and I also know C++.
Here's the thing - I need to create some sort of code that receives information from the back end of a site and dynamically adds a link on an overview page of that new article and also creates a new webpage with the article on it.
I'm not quite sure where to start or how to go about doing this. If anyone could give me a push in how to get started or maybe explain how the code would work?
**The link will reside on a page built with HTML**
Any help is greatly appreciated....
If necessary I'll use PHP (but I don't have any experience with that either :-/ )
Thanks!
redhotspike 0 Newbie Poster
Hey guys: I figured it out...feel free to use as long as ya give me credit :)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
Author: Megan MacDonald
Data Completed: April 23, 2009
Title: Theme Change of a Website
-->
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Part I</title>
<style type="text/css">
.hdln{
color:#3333FF;
font-style:italic;
font-weight:bolder;
}
.prgph{
color:#76B200;
font-variant:small-caps;
}
.hdln2{
color:#FF6600;
font-style:normal;
font-weight: normal;
font-variant: small-caps;
}
.prgph2{
color:#2E0854;
font-variant: normal;
font-family: fantasy;
}
</style>
<script type="text/javascript">
var head;
var par;
function theme2setup(){
//you may want to get the headline element out of the document
head = document.getElementById("headline");
// (1) create new properties to store alternate values
//for each of the h1 properties changed in the stylesheet
//you may want to get the paragraph element out of the document
par = document.getElementById("text");
// (2) create new properties to store alternate values
//for each of the p properties changed in the stylesheet
//end of the function
return;
}
function themechange(){
//you may want to get the headline element out of the document
// (3) store each of the current values in a temporary variable
// (4) set the current style to the alternate style
// (5) set the alternate values to the values saved in the temporary variable
if (head.className=="hdln")
{
head.className = "hdln2";
}
else if (head.className=="hdln2")
{
head.className = "hdln";
}
//you may want to get the paragraph element out of the document
// (6) same as 3 only with the …
redhotspike 0 Newbie Poster
I'm supposed to switch the themes of the "headline" and the "text", but I can't seem to get it. Here's what I have so far...anyone have any ideas why it doesn't work? Thanks :)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Part I</title>
<style type="text/css">
h1{
color:#3333FF;
font-style:italic;
font-weight:bolder;
}
p{
color:#76B200;
font-variant:small-caps;
}
</style>
<script type="text/javascript">
var head;
function theme2setup(){
//you may want to get the headline element out of the document
head= document.getElementById("headline");
// (1) create new properties to store alternate values
//for each of the h1 properties changed in the stylesheet
head.style.color: #FF00CD;
head.style.fontStyle: normal;
head.style.fontWeight: normal;
//you may want to get the paragraph element out of the document
// (2) create new properties to store alternate values
//for each of the p properties changed in the stylesheet
//end of the function
return;
}
function themechange(){
//you may want to get the headline element out of the document
var headOrig=document.getElementById("headline");
// (3) store each of the current values in a temporary variable
var tempColor = headOrig.style.color;
var tempStyle = headOrig.style.fontStyle;
var tempWeight = headOrig.style.fontWeight;
// (4) set the current style to the alternate style
headOrig.style.color=head.style.color;
headOrig.style.fontStyle=head.style.fontStyle;
headOrig.style.fontWeight=head.style.fontWeight;
// (5) set the alternate values to the values saved in the temporary variable
head.style.color=tempColor;
head.style.fontStyle=tempColor;
head.style.fontWeight=tempColor;
//you may want to get the paragraph element out of the document
// (6) same as 3 only with the paragraph element
// (7) same as 4 only with …
redhotspike 0 Newbie Poster
Ok here's the finished program :)
/*~~~prog3.cpp~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| "Waiting ...waiting... Next!" |
| Program 3: A Queuing Simulation |
| |
| This program creates a simulation similar to that of a bank line. |
| The program starts by receiving the user's input data for the |
| number of server, the simulation time, the transaction time, |
| and the average arrival time. Then the program checks to make |
| sure the data is within the scope. |
| Once data is within scope, program commences. The servers are |
| inserted and the transaction_time is initialized. |
| Then the main loop of the simulation commences: the clock is used |
| as an incrementor and when clock reaces simulation time, |
| simulation ends. |
| First, the simulation checks for a new customer. If there is one, |
| the job is enqueued with the current clock as its input value. |
| The number of jobs enqueued is incremented. |
| Next, the program checks the line for any jobs as a test. |
| Then, the program runs through the servers. First, if a server is |
| available and there is someone in line, a job gets dequeued. |
| Then the wait time for that job is computed and added to the |
| total wait time and that server is engaged. |
| Another for loop checks the servers for if they are not available. |
| If …
redhotspike 0 Newbie Poster
ArkM: Thanks for the tip on inserting the code -- didn't realize there was a difference.
Also, this is a presentation, rather a work in progress: I felt like sharing:icon_cool:
And thanks Adam
redhotspike 0 Newbie Poster
Working on a simulation which closely resembles waiting in a line at a bank. Program runs the simulation based on the user's inputs of # of servers, simulation time, average time between arrival, and transaction time. Here's what I have so far:
/*~~~prog3.cpp~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| |
| |
| Author: Megan MacDonald |
| Date Completed: April 3, 2009 |
| Class: CSC 2110, section 002 |
| Tennessee Technological University |
| |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include <iostream>
#include <string>
using namespace std;
#include "Control.h"
#include "server.h"
#include "Queue_of_Jobs.h"
#define Max_Server 10
#define Min_Server 0
#define Max_simTime 10000
#define Min_simTime 0
#define Max_transTime 100
#define Min_transTime 0
#define Max_arrivalTime 100
#define Min_arrivalTime 0
int main()
{
int servers, simTime, transTime, arrivalTime;
//get parameters
cout<<"Number of Servers? ";
cin>>servers;
cout << endl;
while (servers > Max_Server || servers < Min_Server)
{
cout << "The number of servers you entered is outside of scope. " << endl
<< "Please enter a number between 0 & 10: ";
cin >> servers;
cout << endl;
}
cout<<"Simulation Time? ";
cin>>simTime;
cout << endl;
while (simTime > Max_simTime || simTime < Min_simTime)
{
cout << "The simulation time you entered is outside of scope. " << endl
<< "Please enter a number between 0 & 10000: ";
cin >> simTime;
cout << endl;
}
cout<<"Transition Time? ";
cin>>transTime;
cout << endl;
while (transTime > Max_transTime || transTime < Min_transTime)
{
cout << "The transaction time you entered is outside of scope. " << endl
<< "Please …
redhotspike 0 Newbie Poster
Alrighty: here's the completed program -- one issue left is that if there are 2 entries with the same key, the program won't find it. Also, after the third choice, user must enter their choice a second time. But these problems do not otherwise affect the program.
/*~~~linkedlist.h~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| A header file for data of type LinkedList. Private |
| members include: Node *found(), which returns a pointer to a |
| Node that contains the article with the given key or NULL |
| if key isn't found; a class Node, which has public members of |
| data of type ElementType and a pointer next; Node *deleter(), |
| which returns the previous pointer of the node that was being |
| searched for and the node that was found gets deleted; |
| NodePointer first, a pointer to the first node in the |
| linkedlist and; NodePointer predPtr, a pointer initialized to |
| first, but increases as necessary. |
| |
| Operations are: |
| LinkedList(): a constructor that initializes the empty list |
| insert(): inserts the element into the list in sorted order |
| find(): fills item with the article data found in th list |
| erase(): removes the node with the corresponding key and |
| deallocates its memory. |
| |
| Author: Megan MacDonald |
| Date Completed: March 2, 2009 |
| Class: CSC 2110, section 002 |
| Tennessee Technological University |
| | …
redhotspike 0 Newbie Poster
****Note:
Program is not complete: I'm still working on bool erase (const KeyType key);
AND I'm still trying to figure out how to incorporate my Node *LinkedList::find(const KeyType key)
.... it's a private method that returns a Node that contains the article with the given key or NULL if the key is not found...
Any helpful suggestions would be greatly appreciated :)
redhotspike 0 Newbie Poster
Ok...the insert function problem has been solved...
/*~~~linkedlist.h~~~*/
#include <iostream>
#include <string>
using namespace std;
typedef struct Articles ElementType;
typedef std::string KeyType;
struct Articles
{
string key;
string name;
string title;
};
class LinkedList
{
private:
class Node
{
public:
ElementType data;
Node * next;
Node(ElementType dataValue){
data = dataValue;
next = NULL;
}
};
typedef Node * NodePointer;
Node *LinkedList::find(const KeyType key)
{
NodePointer ptr;
ptr = first;
while (ptr != NULL)
{
if (ptr->data.key == key)
return ptr;
else
ptr = ptr->next;
}
if (ptr == NULL)
return NULL;
}
NodePointer first;
NodePointer predPtr;
int mySize;
int index;
public:
LinkedList();
void insert (const ElementType &item);
bool find (const KeyType key, ElementType &item);
bool erase (const KeyType key);
void display();
};
bool operator<(const ElementType &e1, const KeyType &key);
bool operator>=(const ElementType &e1, const KeyType &key);
/*~~~linkedlist.cpp~~~~~*/
#include <iostream>
#include <iomanip>
using namespace std;
#include "linkedlist.h"
LinkedList::LinkedList()
{
first = NULL;
mySize = 0;
}
void LinkedList::insert(const ElementType &dataValue)
{
NodePointer nPtr = new Node(dataValue);
predPtr = first;
NodePointer afterPtr;
if (first == NULL)
{
nPtr->next = first;
first = nPtr;
}
else if (predPtr->data >= nPtr->data.key)
{
nPtr->next = first;
first = nPtr;
}
else
{
while (!((predPtr->next == NULL) || (predPtr->next->data >= nPtr->data.key)))
{
predPtr=predPtr->next;
}
nPtr->next = predPtr->next;
predPtr->next = nPtr;
}
}
bool LinkedList::find(const KeyType key, ElementType &item)
{
LinkedList::NodePointer ptr;
ptr = first;
while (ptr != NULL)
{
if (ptr->data.key == key)
return true;
else
ptr = ptr->next;
}
if (ptr == NULL) …
redhotspike 0 Newbie Poster
typedef Node * NodePointer;
NodePointer is a pointer to a type of class Node. Thus, NodePointer nPtr = new Node(dataValue);
is declaring nPtr as type NodePointer, and it is being set to a new object of class Node, which is receiving the dataValue.
redhotspike 0 Newbie Poster
ok so i fiddle with it some more, managed to get the first node into the list ...here's the insert function (i didn't change any other parts of the program)
void LinkedList::insert(const ElementType &dataValue)
{
NodePointer nPtr = new Node(dataValue);
NodePointer predPtr = first;
if (first == NULL)
{
nPtr->next = first;
first = nPtr;
}
else
{
while ((dataValue.key) >= predPtr->data.key)
{
predPtr=predPtr->next;
}
if ((dataValue.key) == predPtr->next->data.key)
{
nPtr->next = predPtr->next;
predPtr->next = nPtr;
}
}
cout << dataValue.key << " " << dataValue.name << " " << dataValue.title << endl;
}
*note:error is the same as before**, but i know that the problem lies with in the while ((dataValue.key) >= predPtr->data.key)
and if ((dataValue.key) == predPtr->next->data.key)
lines...
**same wording different numbers
3 [main] program2 944 _cygtls::handle_exceptions: Exception: STATUS_ACCESS_VIOLATION
679 [main] program2 944 open_stackdumpfile: Dumping stack trace to program2.exe.stackdump
37260 [main] program2 944 _cygtls::handle_exceptions: Exception: STATUS_ACCESS_VIOLATION
38779 [main] program2 944 _cygtls::handle_exceptions: Error while dumping state (probably corrupted stack)
redhotspike 0 Newbie Poster
another thing to add - when i run the program, this is the error
Crawford:2000:EPa Diane Crawford Editorial pointers
3 [main] program2 3416 _cygtls::handle_exceptions: Exception: STATUS_ACCESS_VIOLATION
619 [main] program2 3461 open_stackdumpfile: Dumping stack trace to program2.exe.stackdump
21228 [main] program2 3461 _cygtls::handle_exceptions: Exception: STATUS_ACCESS_VIOLATION
22159 [main] program2 3461 _cygtls::handle_exceptions: Error while dumping state (probably corrupted stack)
redhotspike 0 Newbie Poster
Ok, so I am befuddled. Each individual file compile fine, no errors. When I compile all together and create an executable, no errors. But, when I run the program, I am getting an error. I have it narrowed down to a problem with my void LinkedList::insert(const ElementType &dataValue)
but I have looked at it too many time to figure out what's wrong. The main concept is that a new node will be inserted in a sorted order based on the key of a struct. The linked list is sorted alphabetically. Also attached is a sample of the data being read in.
/*~~~linkedlist.h~~~~*/
#include <iostream>
#include <string>
using namespace std;
typedef struct Articles ElementType;
typedef std::string KeyType;
struct Articles
{
string key;
string name;
string title;
};
class LinkedList
{
private:
class Node
{
public:
ElementType data;
Node * next;
Node(ElementType dataValue){
data = dataValue;
next = NULL;
}
};
typedef Node * NodePointer;
Node *find (const KeyType &key);
NodePointer first;
int mySize;
int index;
public:
LinkedList();
void insert (const ElementType &item);
bool find (const KeyType &key, ElementType &item);
bool erase (const KeyType &key);
};
bool operator==(const ElementType &e1, const KeyType &key);
bool operator>=(const ElementType &e1, const KeyType &key);
/*~~~linkedlist.cpp~~~~*/
#include <iostream>
using namespace std;
#include "linkedlist.h"
LinkedList::LinkedList()
{
first = NULL;
mySize = 0;
}
void LinkedList::insert(const ElementType &dataValue)
{
NodePointer nPtr = new Node(dataValue);
NodePointer predPtr = first;
if (first->next == NULL)
{
nPtr->next = first;
first = nPtr;
}
else
{
while ((dataValue.key) >= predPtr->data.key)
{ …
redhotspike 0 Newbie Poster
THANK you! ...I always forget about that part
redhotspike 0 Newbie Poster
bool operator>=(const ElementType &e1, const KeyType &key);
I am trying to overload >= which compares the a string in struct e1 with a string. When I compile I get an error that:
'bool operator>=(const ElementType &e1, const KeyType &key);' must take exactly one argument
...I understand that the error is probably from trying to compare a struct element with a string, but i do not know how to fix it.
redhotspike 0 Newbie Poster
Ok classes seem to be working fine -- I'm posting them in case anyone runs into this kind of program. They all compile without any errors :D
player.h
#include <iostream>
#include <string>
using namespace std;
class Player
{
private:
string playerName;
public:
void getName(string n);
int getIndex();
};
player.cpp
#include <iostream>
#include <string>
using namespace std;
#include "player.h"
#include "tictactoe.h"
void Player::getName(string n)
{
playerName = n;
cout << playerName;
}
int Player::getIndex()
{
srand((unsigned)time(0));
int random_integer = rand();
if (random_integer%2)
return 2;
else
return 1;
}
tictactoe.h
#include <iostream>
#include <string>
using namespace std;
class Tictactoe
{
private:
int row, col;
char square[3][3];
public:
Tictactoe();
void displayBoard(ostream & out);
bool setValue(int row, int col, char player);
int getStatus();
};
tictactoe.cpp
#include <iostream>
#include <string>
using namespace std;
#include "tictactoe.h"
Tictactoe::Tictactoe()
{
row = 0;
col = 0;
char player = '\0';
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 3; j++)
{
square[i][j] = player;
}
}
}
void Tictactoe::displayBoard(ostream & out)
{
out << endl << endl
<< " " << square[1][1] << " | " << square[1][2] << " | " << square[1][3] << endl
<< " -----------" << endl
<< " " << square[2][1] << " | " << square[2][2] << " | " << square[2][3] << endl
<< " -----------" << endl
<< " " << square[3][1] << " | " << square[3][2] << " | " << square[3][3] << endl …
redhotspike 0 Newbie Poster
tictactoe.h
class Tictactoe
{
private:
int s[9];
int row, col;
char square[3][3];
char board[3][3];
public:
Tictactoe();
void displayBoard();
void placement();
bool checkForWin();
bool checkSpot(int row, int col);
};
player.h
class Player
{
private:
string playerName;
public:
void getName(string name);
int choose(int &player);
};
redhotspike 0 Newbie Poster
Thank you. I took your advice and made some changes, as well as added some:
(just putting the class files down for now since they are what I'm struggling with)
tictactoe.cpp
#include <iostream>
using namespace std;
#include "tictactoe.h"
Tictactoe::Tictactoe()
{
row = 1;
col = 1;
for (int i = 1; i < 4; i++)
{
for (int j = 1; j < 4; j++)
{
board[i][j] = 0;
square[i][j] = ' ';
}
}
}
void Tictactoe::displayBoard()
{
for ( int row = 1; row < 4; row ++)
{
for ( int col = 1; col < 4; col++)
{
if ( board[row][col] == 0)
{
square[row][col] = ' ';
}
if ( board[row][col] == 1)
{
square[row][col] = 'X';
}
if ( board[row][col] == 2)
{
square[row][col] = 'O';
}
}
}
cout << endl << endl;
cout << " " << square[1][1] << " | " << square[1][2] << " | " << square[1][3] << endl;
cout << " -----------" << endl;
cout << " " << square[2][1] << " | " << square[2][2] << " | " << square[2][3] << endl;
cout << " -----------" << endl;
cout << " " << square[3][1] << " | " << square[3][2] << " | " << square[3][3] << endl << endl;
}
void Tictactoe::placement()
{
cout << "Which row please? " << endl;
cin >> row;
cout << "Which column please? " << endl;
cin >> col;
if (row == 1)
{
if (col …
redhotspike 0 Newbie Poster
Hey there. I am taking a programming class using C++ and my assignment is to create "Tictactoe" using ObjectOrientedProgramming... The problem is I have no idea what I am doing...
I need to have a "tictactoe" class file and a "player" class file - each with their own header files and one driver file.
"You will need to have two classes: a TicTacToe class and a Player class. The TicTacToe class should contain the above mentioned 2D array for representing the game board, i.e., this class should have a 2D array of characters as its data member. You should have a zero-argument constructor in the TicTacToe class that will generate the initial game state (all the 2D array elements initialized to '\0'). You should overload the << operator to display the game board at any point. The game board should be displayed along with the grid as shown in the sample executions. There should also be a member function called SetValue that will have three arguments (a row index, a column index, and an integer representing the player index) and a boolean return type. This function will set the specified cell of the 2D array to an appropriate character depending on the player index. This function should also make sure that a player makes its move to a blank and valid (inside the array bounds) position. In case a player wants to make a move to an invalid or already occupied position, it should return false. In case …