Jump to content

MSVSora

Member
  • Posts

    57
  • Joined

  • Last visited

Reputation Activity

  1. Informative
    MSVSora got a reaction from rcarlos243 in [HELP]How do I break between If else on C++?   
    In your else statement add "if(i != 0){ your string thingy; }" <- this way only if you have tries remaining will it output the message
  2. Like
    MSVSora got a reaction from uzarnom in SQL Question   
    Not an SQL expert but something like this?
     
    SELECT SUBQUERY.Title, SUBQUERY.Composer FROM ( SELECT shows.Title as Title, shows.Composer_Name as Composer, casting.Dancer_ID as Dancer_ID FROM shows INNER JOIN casting ON shows.Show_ID=casting.Show_ID ) AS SUBQUERY INNER JOIN dancers on SUBQUERY.Dancer_ID=dancers.Dancer_ID WHERE dancers.Country='England'  
    Edit:
     
    To setup the database in my mysql setup had to change a bit of your initial SQL code to
    drop table if exists casting; drop table if exists shows; drop table if exists dancers; create table Shows( Show_ID INTEGER NOT NULL, Title VARCHAR(30), Composer_Name VARCHAR(30), Genre VARCHAR(10), Primary Key (Show_ID) ); create table Dancers( Dancer_ID INTEGER NOT NULL, Dancer_Name VARCHAR(30), Country VARCHAR(20), Primary Key (Dancer_ID) ); create table Casting( Show_ID INTEGER NOT NULL, Dancer_ID INTEGER NOT NULL, Character_Name VARCHAR(30), Primary Key (Show_ID, Dancer_ID), Foreign Key (Show_ID) references Shows(Show_ID), Foreign Key (Dancer_ID) references Dancers(Dancer_ID) ); INSERT INTO Shows Values(100, 'Cats', 'Andrew Lloyd Webber', 'Fantasy'); INSERT INTO Shows Values(200, 'Les Miserables', 'Alain Boublil', 'Historical'); INSERT INTO Shows Values(300, 'Wicked', 'Stephen Schwartz', 'Fantasy'); INSERT INTO Shows VALUES(400, 'Phantom of the Opera', 'Andrew Lloyd Webber', 'Romance'); INSERT INTO Dancers Values(10, 'Sherlock Holmes', 'England'); INSERT INTO Dancers Values(15, 'Jane Austen', 'England'); INSERT INTO Dancers Values(20, 'John Knightly', 'USA'); INSERT INTO Casting VALUES (100, 10, 'Gus'); INSERT INTO Casting Values (200, 15, 'Fantine'); INSERT INTO Casting Values (300, 20, 'Wizard'); INSERT INTO Casting Values (400, 15, 'Christine');  
  3. Informative
    MSVSora got a reaction from rcarlos243 in [HELP]How do I break between If else on C++?   
    The problem you are seeing here is because of your scope. In C++ a scope is defined by the '{' and '}' brackets. When you use "if(bool) statement;" it basically just creates the scope for the single line, so when you are trying to use break, it creates it after that scope, so your code actually looks something like this
     
    while(true) { if (i == 0) { break; } i = i - 1; cout << "Enter your password " ; getline(cin, input); if ( input == "P@ssw0rd") { cout << "In " << years << " years, $" << D << " deposited per month will grow to $" << S ; } break; else { cout << "incorrect, password! " << i <<" more try limit\n"; } } while what you probably want is something more like this
     
    while(true) { if (i == 0) { break; } i = i - 1; cout << "Enter your password " ; getline(cin, input); if ( input == "P@ssw0rd") { cout << "In " << years << " years, $" << D << " deposited per month will grow to $" << S ; break; } else { cout << "incorrect, password! " << i <<" more try limit\n"; } }  
    also rather than and a while you probably want to use a for loop
  4. Informative
    MSVSora got a reaction from rcarlos243 in [HELP]How do I break between If else on C++?   
    A switch case is written by doing the following
     
    //enums also work here switch(integer variable) { case integer value: //code here break; case integer value2: //code here break; default: //code here break; } Though this wouldn't help you much, personally I would write the code something like this
     
    const int maxNrOfTrys = 5; for (int i = 0; i > 0; i = maxNrOfTrys; --i) { cout << "Enter your password "; getline(cin, input); if ( input == "P@ssw0rd") { cout << "In " << years << " years, $" << D << " deposited per month will grow to $" << S ; break; } else { cout << "incorrect, password! " << i <<" more try limit\n"; } }  
  5. Agree
    MSVSora got a reaction from ohJey in C++ Reverse Encryption   
    Well first step ofc is ofc the -33 so we have (n - 33) rev mod 90  ^ 2
     
    Now modulus is just the remainder of the divide, so we know that (n - 33) is what was left from 90 which gives us an infinite amount of possibilities
    So now we have (n - 33) + (any of 90's multiples) ^ 2
     
    Alright so that's simple enough right? Of course at this point I am taking the piss as you can't reverse a modulus, that's why it's used for hashing http://mathforum.org/library/drmath/view/51619.html
     
    Though if you can figure out a way to reverse modulus the hackers of the world will surely thank you  
     
    Edit:
     
    Basically what this code does is hash the value you enter, not encrypt it a basic explanation can be found here - http://www.securityinnovationeurope.com/blog/whats-the-difference-between-hashing-and-encrypting
  6. Informative
    MSVSora got a reaction from ExplOregon in Statically allocated arrays to Dynamically C++   
    Well, you have a function which is called "addAnimal", in this function you would want to basically, check the current animal count (which you need to store in the class as a member variable and default it to 0 along with having another member variable for the current max size of the array. If the current animal count is the same as the max size of the array, you want to then call a new function which will resize your array to a size you specify, which would be the code previously given.
     
    void animal_shelter::growArray(unsigned int aNewArraySize) { assert(aNewArraySize > 0 && "Invalid array size in animal_shelter::growArray"); animal* newArry = new animal[aNewArraySize]; memcpy(newArry, myAnimalList, sizeof(animal) * myCurrentAnimalListSize); myAnimalListMaxSize = aNewArraySize; delete[] myAnimalList; myAnimalList = newArry; } So basically the new function would look something like this
    Function definition Safety check to make sure we don't try to create an array with 0 size (It will crash the program if the value is equal to 0 http://www.cplusplus.com/reference/cassert/assert/ requires the assert.h header) Create a new animal array of specified size Copy the old list of animals to the new array, this will make sure that we only move animal elements we have filled by moving the active size of the array rather than the whole array Set the current max size of the array to the new max array size Delete the old array Assign member variable myAnimalList to the new array A couple of notes here, first I have added the prefix of "my" to all member variables and the prefix of "a" to the argument, this is just part of the code standard I use to help make the code more legible.
    Secondly the assert is by no means needed and is just something I added as its something I always do, really though if you are going to add asserts you should also run assert on the case that the new array size is smaller than the current number of animals in your array as this would cause an error when copying the memory but that may be a bit advanced for what your teacher expects.
     
    Feel free to ask if you have any further issues
  7. Informative
    MSVSora got a reaction from ExplOregon in Statically allocated arrays to Dynamically C++   
    It would go in the top of the function as you want to increase the size of the array before adding, otherwise you will be trying to add to a full array
  8. Informative
    MSVSora got a reaction from ExplOregon in Statically allocated arrays to Dynamically C++   
    Sure, though first I should point out that your code wont work anyway for a couple of reasons. Maybe you are just testing atm but your addAnimal function in its current state will do nothing, except allocate new memory then delete the old.
     
    Anyway to the main function it should look something like
     
    int main() { animalShelter shelter; //create new animalShelter //As your addAnimal function requires an animal we must first create one animalShelter::animal bob; //As you have your animal struct inside of animalShelter then we have to use the animalShelter scope, I would recommend moving the animal decleration to outside of the animalShelter class. bob.name = "Bob"; bob.age = 10; bob.breed = "Robot"; bob.weight = 2000; bob.friendly = "No clue"; //Not sure what this is supposed to be but seems like something that should be a bool? bob.description = "Some random text here about Bob"; shelter.addAnimal(bob); //This is rather weird to do considering you also require the input inside the addAnimal function shelter.displayAll(); //This will currently not display anything as you currently don't actually store the animal return 0; }  
    Also I would recommend you post your testing.h and testing.cpp to pastebin or similar when asking for help as it makes the code a lot easier to read
     
    One thing I have to comment on is your inclusion of "using namespace std" in the header file. This is a big no no, most people will tell you that the "using namespace" thing is just bad in general which isn't always true, but that is another discussion. If you are to use the "using namespace" you should only include it in your cpp file. This is mainly to keep from getting ambiguous reference errors. 
  9. Like
    MSVSora reacted to ExplOregon in Statically allocated arrays to Dynamically C++   
    Thank you so much for all of your help, I appreciate it! I'll be sure to PM you if I still cannot
    figure it out after the videos, I've come across those videos before and they do a great job
    putting the concepts in simple terms. Thanks again!
  10. Agree
    MSVSora reacted to DevBlox in Why is Java so slow?   
    It's not slow, it is just suited to other tasks. It can be faster than say C in some cases (stands for any statically compiled language), because compiled C code  is completely static, while Java code is interpreted by a very clever virtual machine that optimizes code in run-time. That means complex tasks are dynamically micro-optimized, meaning it no longer has static performance,  it  is potentially higher than let's say C. This also makes return in (time) investment of Java humiliatingly larger than C basically. That's why more people write business software with Java than with C (*khem* nobody sane enough writes them with C *khem*).
     
    There are cons to it though. Like the garbage collector.  And in general some algorithms/cases require things that Java is bad at and can't solve with Java gracefully. Things like:
    > Creating many tiny objects continuously and dismissing them almost immediately (means GC will work overtime and your application will stutter, because "stop the world" pauses happen, eg. Minecraft).
    > Working with system resources and "hard real-time" problems. As I mentioned Java has it's garbage collector that destroys your objects, when they are no longer in use. This means an object's lifetime is no longer deterministic, and it will often free resources whenever it feels like it. This is bad in certain and mentioned situations, when resources have to be quickly freed up for some other process/thread to use. That's why normal people use C++ for these things (it is built upon RAII paradigm, which is why it is so good for resource handling).
     
    These are only couple of things from the top of my head. These are also reasons why games written in Java suck performance wise, why nobody writes operating systems in Java (while in theory you could). Also such a system has more easily detectable security holes, which is why Java is not considered safe even now when a lot of problems are solved (and comparing it to .NET is bullshit, because .NET was created to build upon Java's failures, of course it is better, I like C# as a language more, but I still code Java whenever I can, because I don't have to deal with Mono on my Linux machine, it's definitely usable though, but not perfect). Also needing to JVM for a Windows desktop program is bullshit, so DON'T write one with Java, 'cause I will be mad, write it with C# on Mono instead if you want it to be multi-platform. Rant over lolz.
     
    TL;DR: Stupid people use whatever tools for whatever and then complain that they are slow. That's why Java is "slower" than C or C++.
     
    EDIT: Actually I figured I'd add a point or two to stop people from thinking I'm a complete lunatic for thinking Java perf > C perf all day everyday.
    > The virtual machine is big and takes time to start up.
    > Since JVM optimizes run time there is a warmup period for applications.
    > Eats RAM more than C/C++, as .NET would do too (.NET is a bit more clever at that point though, I could expand on this), but it is definitely worth it these days (besides it's not that terribly much)
     
    Also Java gives you the opportunity to nail it on the code quality and design, so no need to hold back, because you're hurting yourself.
  11. Like
    MSVSora reacted to Teef2009 in Personal Rig Update 2015 Part 5 - The Final Deployment   
    I've been trying to find the sketchup file of the design shown in Part 2, did you upload it onto 3D Warehouse? If so, what is it called?
     
  12. Agree
    MSVSora got a reaction from Gachr in Useless game dev discussion   
    @LOLZpersonok First of all, please calm down we are just trying to help as you requested in your original post.
     
    Now as to your claim that we didn't read your original post, that isn't the case. Your exact wording being 
    This does not say anything about getting experience in programming games. There is a huge difference in developing applications and developing games. "It'll dabble in game development, but it won't be enough for, say, a job application at most game studios." This obviously shows that you will have no where near enough experience to start working on this game even once you have finished college and probably even for many years after if you have no intention of working at a game studio. The scope that you specified was that of a AAA corporation not a single studio and definitely not a single person. It would require over a thousand years of development time for a single person to be able to pull something like this off (this is of course a rough estimate only taking into account most AAA studios avg dev time for close to this scope of a game and them only having to work 8 hour work days). 
     
    Now about your drama post. I believe the more accurate message to take from Gachr's message is to just drop this project as it is too big and try just working on something smaller instead  
     
    I hope you have a good day and good luck with your project
×