Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions C++/64_cppBeginners.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include <iostream>
#include <fstream>
using namespace std;

int main()
{
ofstream buckyFile;
buckyFile.open("tuna.txt");

buckyFile << "I love tuna and tuna loves me!\n";
buckyFile.close();
}
17 changes: 17 additions & 0 deletions C++/65_cppBeginners.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <iostream>
#include <fstream>
using namespace std;

int main()
{
ofstream buckysFile("beefjerky.txt");

if(buckysFile.is_open()){
cout << "okt he file is open" <<endl;
}else(
cout << "bucky you messed up" << endl;
)

buckysFile << "oi love the beef!\n";
buckysFile.close();
}
23 changes: 23 additions & 0 deletions C++/66_cppBeginners.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include <iostream>
#include <fstream>
using namespace std;

int main()
{
ofstream theFile("players.txt");

cout << "Enter palyers ID, Name, and Money" << endl;
cout << "press Ctrl+Z to quit\n" <<endl;

int idNumber;
string name;
double money;

while(cin >> idNumber >> name >> money)
{
theFile <<idNumber << ' ' << name << ' ' << money << endl;

}

}

20 changes: 20 additions & 0 deletions C++/67_cppBeginners.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include <iostream>
#include <fstream>
using namespace std;

int main()
{
ifstream theFile("players.txt");

int idNumber;
string name;
double money;

while(theFile >> idNumber >> name >> money)
{
cout <<idNumber << "," << name << "," << money << endl;

}

}

33 changes: 33 additions & 0 deletions C++/68_cppBeginners.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#include <iostream>
#include <fstream>
using namespace std;

int getWhatTheyWant();

//main function

int main(){

int whatTheyWant;

whatTheyWant = getWhatTheyWant();

while(whatTheyWant != 4){

whatTheyWant = getWhatTheyWant();
}
}

//getWhatTheyWant function
int getWhatTheyWant(){
int choice;

cout << "1 - just plain items" <<endl;
cout << "2 - helpful items" <<endl;
cout << "3 - harmful items" <<endl;
cout << "4 - quit program" <<endl;

cin >> choice;
return choice;

}
76 changes: 76 additions & 0 deletions C++/69_cppBeginners.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#include <iostream>
#include <fstream>
using namespace std;

int getWhatTheyWant();
void displayItems(int x);

//main function
int main(){

int whatTheyWant;

whatTheyWant = getWhatTheyWant();

while(whatTheyWant != 4){
switch(whatTheyWant){
case 1:
displayItems(1);
break;
case 2:
displayItems(2);
break;
case 3:
displayItems(3);
break;
}

whatTheyWant = getWhatTheyWant();
}
}

//getWhatTheyWant function
int getWhatTheyWant(){
int choice;

cout << "1 - just plain items" <<endl;
cout << "2 - helpful items" <<endl;
cout << "3 - harmful items" <<endl;
cout << "4 - quit program" <<endl;

cin >> choice;
return choice;

}

//display items function
void displayItems(int x){

ifstream objectFile("objects.txt");
string name;
double power;

if(x==1){
while(objectFile >> name >> power){
if(power==0){
cout << name << ' ' << power << endl;
}
}
}
if(x==2){
while(objectFile >> name >> power){
if(power>0){
cout << name << ' ' << power << endl;
}
}
}

if(x==3){
while(objectFile >> name >> power){
if(power<0){
cout << name << ' ' << power << endl;
}
}
}

}
76 changes: 76 additions & 0 deletions C++/70_cppBeginners.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#include <iostream>
#include <fstream>
using namespace std;

int getWhatTheyWant();
void displayItems(int x);

//main function
int main(){

int whatTheyWant;

whatTheyWant = getWhatTheyWant();

while(whatTheyWant != 4){
switch(whatTheyWant){
case 1:
displayItems(1);
break;
case 2:
displayItems(2);
break;
case 3:
displayItems(3);
break;
}

whatTheyWant = getWhatTheyWant();
}
}

//getWhatTheyWant function
int getWhatTheyWant(){
int choice;

cout << "\n1 - just plain items" <<endl;
cout << "2 - helpful items" <<endl;
cout << "3 - harmful items" <<endl;
cout << "4 - quit program" <<endl;

cin >> choice;
return choice;

}

//display items function
void displayItems(int x){

ifstream objectFile("objects.txt");
string name;
double power;

if(x==1){
while(objectFile >> name >> power){
if(power==0){
cout << name << ' ' << power << endl;
}
}
}
if(x==2){
while(objectFile >> name >> power){
if(power>0){
cout << name << ' ' << power << endl;
}
}
}

if(x==3){
while(objectFile >> name >> power){
if(power<0){
cout << name << ' ' << power << endl;
}
}
}

}