// ps3.cpp : Defines the entry point for the console application.

#include "stdafx.h"
#include "URLContainer.h"

using namespace std;

bool isBalanced(string p){
	stack<char> s;
	for (int i =0 ;i < p.size(); i++){
		if (p[i] == '(')
		else if (p[i] == ')') {
			if (s.empty())
				return false;
			else s.pop();
		//anything else we ignore.
	if (s.empty())
		return true;
	return false;


int main(int argc, char* argv[])

	//This is the first part of the PS.
	//You must implement isBalanced(string s) so that it checks
	// for balanced parenthesis.
	string line;
	getline(cin, line); //you will neet to press Enter twice.
	if (isBalanced(line)) //you must implement this function
		cout << "Its a Balanced expression" << endl;
		cout << "It is NOT Balanced" << endl;

	ifstream opendir("//Engr_asu/ECE352/computer_science.txt");
	if (opendir == 0) {
		cout << "Could not open input file" << endl;
	URLContainer uc(opendir); //read the whole file into uc

	//print out the number of URLs we read.
	cout << "There were " << uc.size() << " URLs"<< endl; 
	uc.printFirstN(cout, 3); //print the first three.

	uc.printNth(cout, 11); //print the 11th item

	uc.sortByURL(); //sort alphabetically by URL
	cout << "===First three, sorted by URL" << endl;
	uc.printFirstN(cout, 3); //checking to make sure they are OK

	cout << "===First three, sorted by title" << endl;
	uc.printFirstN(cout, 3);

	return 0;