Jump to content

  • Log In with Google      Sign In   
  • Create Account

Savalric

Member Since 21 Dec 2012
Offline Last Active Nov 08 2013 02:31 PM

Topics I've Started

Need Help with program

06 November 2013 - 10:51 PM

Alright, this is homework and I'm having a problem with it running.

 

SnowData.cpp:

#include <string>
#include <iostream>
#include <cstdlib>
#include <iomanip> 
#include "SnowData.h"

using namespace std;


double SnowData::getAverage()
{
	double total;
	    for(int i=0; i < 6; i++)
		{
		total = inches[i];
		inches[i] = inches[i+1];
		}
		double average = total/7;
		return (average);

}

void SnowData::print()
{
	for (int i = 0; i < 7; i++)
	{
		cout << SnowData::monthname;
		cout << " " << date[i] << setw(10) << inches[i] << endl;
	}
}
//SnowData snow_data("January", sdate, snow_inches);
/*	int date[7];
	//int enddate;
	double inches[7];
	string monthname;
	int startdate;*/
SnowData::SnowData(string mname, int snowdate[7], double snowinches[7])
{
	monthname = mname;
	for (int i=0; i < 7; i++)
	{
		date[i] = snowdate[i]; 
	}
		
	for (int i=0; i < 7; i++)
	{
		inches[i] = snowinches[1];
	}
}

void SnowData::sortByInches()
{
	for (int j = 0; j < 7; j++) 
	{
		for (int i = 0; i < 7; i++)
		{
			if (inches[i] > inches[i+1])
			{
				double temp = inches[i];
				int temp1 = date[i];
				inches[i] = inches[i+1];
				date[i] = date[i+1];
				inches[i+1] = temp;
				date[i+1] = temp1;
			}
		}
	}
}
void SnowData::sortByDate()
{
		for (int j = 0; j < 6; j++) 
	{
		for (int i = 0; i < 6; i++)
		{
			if (date[i] > date[i+1])
			{
				double temp = date[i];
				int temp1 = inches[i];
				date[i] = date[i+1];
				inches[i] = inches[i+1];
				date[i+1] = temp;
				inches[i+1] = temp1;
			}
		}
	}
}

SnowData.h

#include <string>
#include <iostream>
#include <cstdlib>
#include <iomanip>
using namespace std;
class SnowData
{
private:
	int date[7];
	//int enddate;
	double inches[7];
	string monthname;
	int startdate;
public:
	double getAverage();
	void print();
	SnowData( string, int[7], double[7]);
	void sortByDate();
	void sortByInches();
};

ClassTester.cpp:

#include<iostream>
#include <iomanip>
#include <cstdlib>
using namespace std;
#include "SnowData.h"

const int DAYS_IN_PERIOD = 7;

int main()
{                  
    double snow_inches[7]; 
    int sdate[7];
    for(int i=0; i < 7; i++)
	{
		cin >> snow_inches[i]; // = (double(rand() % 60)) / 3;
	}
	cout << "Enter the Start Date: ";
	cin >> sdate[0];

	int x = sdate[0];

    for(int i=0; i < 7; i++)
	{
        sdate[i] = x++;
		// = (double(rand() % 60)) / 3;
	}
    SnowData snow_data("January", sdate, snow_inches);
   
    snow_data.sortByInches();
    cout << "--------- Sorted by Inches ---------\n";
    snow_data.print();

    snow_data.sortByDate();
    cout << "---------- Sorted by Date -------\n";
    snow_data.print();

    cout << "Average snowfall = " << setprecision(2)
        << snow_data.getAverage() << " inches\n";
	system("Pause");
    return 0;
}

We had to run it like this in three files (2 sources and a header) to illustrate a point. When it runs, it only displays the second element in the inches[] array, and it also averages incorrectly. I feel like it something simple that I'm missing, a > sign that needs to be switched or something, but I can't get it. Btw, there is some useless data in there (like DAYS_IN_PERIOD,) because the method I chose to do things let me enter user data instead of randomizing things and automated the date filling in process. But it was originally my teachers tester class so I had to comment it out.

 

P.S. If gamedevs policy is not help with homework period, then I apologize in advanced, but I led to understand that help with errors was another thing.


Need Help with Homework

04 November 2013 - 07:50 PM

I'm not sure if this is the write place for these kind of questions but it's the only forum I know at the moment for programming (i've heard of dreamincode but never been there personally). Basically, I need to create a class that works with this code:

#include<iostream>
#include <iomanip>
#include <cstdlib>
using namespace std;


const int DAYS_IN_PERIOD = 7;

int main() 
{                  
    double snow_inches[7];
    
    for(int i=0; i < 7; i++)
        snow_inches[i] = (double(rand() % 60)) / 3;

    SnowData snow_data("January", 12, 19, snow_inches);
    
    snow_data.sortByInches();
    cout << "--------- Sorted by Inches ---------\n";
    snow_data.print();

    snow_data.sortByDate();
    cout << "---------- Sorted by Date -------\n";
    snow_data.print();

    cout << "Average snowfall = " << setprecision(2) 
        << snow_data.getAverage() << " inches\n";

    return 0;
}

This is the assignment:

 

Write a program that can be used by a ski resort to keep track of local snow conditions for one week. It should have a seven-element array of structures, where each structure holds a date and number of inches of snow in the base on that date. The program should have the user input the name of the month, start and end dates of the seven day period being measured, and then the seven base snow depths. The program should then sort the data in ascending order by base depth and display the results. Here is a sample report.

Snow Report December 12-18

Date Base
13 42.3
12 42.5
14 42.8
15 43.1
18 43.1
16 43.4
17 43.8

 I don't necessarily need you guys to do all of my homework for me, but I don't understand classes very well (I understand them in structure but not in purpose or use.) So far, I've used cpluplus.com as well as the book this assignment is from to learn them to no avail. The assignment is due in like 5 hours so if someone could either teach/talk me through this assignment or write it for me and explain each component, you'd have my many thanks. I've have a test on this subject matter and so far I don't understand it at all. 


Magic in RPGs

16 September 2013 - 01:28 AM

I have an idea for a game concept. I won't go into details, but this is my first game and I was wondering exactly whether or not I should incorporate magic into the game. Magic and rpgs go hand in hand, it has since the dawn of time. Obviously, the goal is to make a game that I love making, and that people love playing (and paying me for it of course). Will I be burning any bridges by not including magic? including magic wouldn't be difficult at this stage of development, but I'm not sure if I should. I was hoping to create a realistic, immersive survival based rpg, and magic would somewhat make it difficult to maintain a completely realistic game.

 

Some of the ideas I was experimenting with involved perhaps just having magic be a side skill like in some games, where it aids other skills. Other ideas would be to have magic be in it's infancy, where it's more of a play toy than an actual skill. I've considered full blown out magic skills similar to destruction, restoration, black and white magic, etc..., but having guns, bows/thrown weapons, swords and other melee weapons, as well as martial arts could make it even more difficult than it already is to balance, as well as overloading the game with far too many combat options.

 

I guess my question is simple: What's your take on including magic in an rpg, or rather, leaving it out? What are some pitfalls that I should avoid when using it? And what kind of implementation do you think I should take?


Maximum Landsize in a console game

26 August 2013 - 02:59 PM

As the title suggest, I was wondering just how large a landmass a console could generate (Both current and next gen). I wanted to make a rather simplistic game that had a large landmass. So, for example, you took skyrim, removed the npcs, removed the dragons, the mobs, the respawn scripts and turned it into a sprawling continent, with a semi destructive environment similar to battlefield 3's frost engine and a simplistic crafting system like minecraft's. Graphics wise, i was thinking something like Deus Ex/Skyrim-esque with modern skyscrapers (completely intact and capable of ascending) and farmland/forest/lake on the outskirts with towns and villages scattered inbetween as well as the inevitable unending ocean so as to stop ppl from traveling too far.


Young Life Crisis

23 May 2013 - 11:12 AM

So, I know there are a lot of sites on this but my research has been rather varied in results. I just finished my first year of college and I'm wondering if I should even continue. My end goal is to Design games. I was thinking that I should learn programming and use that as an in-route into designing, but I recently found out that it's not necessary. So I was thinking of getting a degree in Game design and studying programming on my own time to known the limitations. But tbh, I'm rather confused on what the best avenue would be. Like I said, the end goal is design. I know that potential employers look at your experience (mods, games, etc...), but I don't want to invest myself needlessly. As in, I don't want to waste 4 years of my life for a CS or Game Design degree (or certificate if employers would accept that), not to mention about 100 grand, when I could simply learn on my own in a year, and arrive at the same place.

 

I guess what I'm asking is: Do I need a degree to validate my knowledge? Should I just focus on creating work, mods, and games (flash/java games) and learning programming languages? If I write a few GDDs, would that be adequate enough to get me a junior designer gig? (and I mean like some really great GDDs because, like all gamers, I have some really good ideas lol).


PARTNERS