Jump to content

madknight3

Member
  • Posts

    1,786
  • Joined

  • Last visited

Everything posted by madknight3

  1. Then you should be able to start by designing and setting up your database tables and queries. That doesn't require any C++ and it's good to know what your database input/output needs to look like. If you're not familiar with MySql or how to work with it, then there are plenty of tutorials you can find online. Like this for example. Once you have that, then you can write some functions in C++ that executes the queries you planned out. If you're not familiar with how to do this, then I'm sure you can find a tutorial online. Like this for example. Note that this information isn't specific to your project. You learn how to work with MySql in C++, then you apply it to your specific project. You can probably do up all the math functions (for wages and stuff) at this point too. After all, none of this stuff needs to depend on the GUI. That should be all you need to get started on the UI portion. Again, the information doesn't have to be specific to your project. Like the following Knowing how to add controls to the UI (example: drag and drop from Visual Studio designer) Knowing how to get input from the controls (example: getting text from a textbox) Knowing how to display output in the controls (example: putting text in a label) Knowing how to work with control events (example: running code on a button click) Use what you learn from those basic tutorials and apply them to your project. When you run into something that the tutorials didn't cover, then google for that information.
  2. There's no way to know how long a piece of code will take to run on a given machine, that's what benchmarking is for. You can do a theoretical analysis of your algorithm and determine it's time complexity (if you know how) however that can only tell you so much. The differences between your time and your teachers/the other guys could be because Your hardware is faster Your algorithm is better Your algorithm is wrong (ie: it's not doing stuff it's supposed to do, making it seem faster) etc
  3. That's fine. I just wanted to give the OP my take on the answer and show the difference between the MySql and Sql Server limit syntax. In many cases this can work fine and it's probably fine for the OPs use case, although they doesn't really say what that is. Still, I don't think it's a better practice than using a DateTime column which was created for this very purpose (which the OP states they have in the table). Also, as far as I know there's no guarantee that auto increment will keep the proper order in scenarios where the database receives multiple inserts at around the same time. This might not be an issue for the OPs use case, but it's worth mentioning.
  4. You can also get it directly from your SQL query with DATEPART SELECT DATEPART(year, End_time) FROM Table
  5. The DateTime object has an Hour property. If your dates are stored as a DateTime type in your database then you can simply cast it. var endTime = (DateTime) reader["End_time"]; int hour = dt.Hour; // or in one line int hour = ((DateTime) reader["End_time"]).Hour; If your dates are stored as a string in your database (they probably shouldn't be without a good reason) then you can convert them with Convert.ToDateTime() or DateTime.Parse(). Here's an example with DateTime.Parse(). var endTime = DateTime.Parse(reader["End_time"].ToString()); int hour = dt.Hour; // or in one line int hour = DateTime.Parse(reader["End_time"]).Hour; Convert.ToDateTime() and DateTime.Parse() will both throw exceptions if the column doesn't contain a valid DateTime, so it's often better to use DateTime.TryParse() int hour; DateTime dt; if (DateTime.TryParse(reader["End_time"], out dt)) { // Parse was successful, dt contains the converted DateTime hour = dt.Hour; } else { // Parse Failed, dt contains DateTime.MinValue } // In C# 7 you can shorten this a little if (DateTime.TryParse(... , out DateTime dt)) // Note that dt is declared here instead of above { // ... }
  6. Note that this may not be correct. What if the largest ID isn't the most recent insert? You didn't specify if that could happen or not. Isn't that why you have a date column? It also returns all rows from the table instead of just a single row. See my post for more info (I made a large edit)
  7. Limit appears to be for MySql databases. Sql Server uses TOP. Also you want to order by your date column since that's how you know which record was inserted most recently. SELECT TOP(1) Id FROM Table ORDER BY DateColumn DESC Usage in C# would be something like this string id; using (var connection = new SqlConnection(connectionString)) { connection.Open(); var query = "SELECT TOP(1) Id FROM Table ORDER BY DateColumn DESC"; using (var command = new SqlCommand(query, connection)) // When using statements are declared right using (SqlDataReader reader = command.ExecuteReader()) // next to each other you can skip the nesting { if (reader.Read()) { id = reader["Id"].ToString(); } } } If you ever need to include WHERE in your SQL, then that could look more like this string id; using (var connection = new SqlConnection(connectionString)) { connection.Open(); var query = "SELECT TOP(1) Id FROM Table WHERE NameColumn = @Name ORDER BY DateColumn DESC"; // Note the WHERE. Name is just an example using (var command = new SqlCommand(query, connection)) { command.Parameters.AddWithValue("@Name", nameVariable); // Note the command parameter to protect against SQL injection // Here is another way to declare a parameter. It's a little more verbose, but it doesn't assume the type for you. // command.Parameters.Add("@Name", SqlDbType.NVarChar).Value = nameVariable; using (SqlDataReader reader = command.ExecuteReader()) { if (reader.Read()) { id = reader["Id"].ToString(); } } } } In this case, because you're only returning a single value you can also get rid of the reader and use SqlCommand.ExecuteScalar string id; using (var connection = new SqlConnection(connectionString)) { connection.Open(); var query = "SELECT TOP(1) Id FROM Table ..."; using (var command = new SqlCommand(query, connection)) { // add parameters if necessary var result = command.ExecuteScalar(); if (result != null && result != DBNull.Value) { id = result.ToString(); } } } If you're not familiar with the using statements, they will automatically dispose of objects (that implement IDisposable) when they're done. It's generally a good practice to use them. You can leave the using statements out, but it's still good practice to manually call the dispose method of the objects when you're done with them.
  8. You can change a bunch of things, like the theme, in the settings (found under File -> Settings) For complete IDE themes it's under "Appearance & Behavior -> Appearance" For editor only, it's under "Editor -> Colors & Fonts" If one of the included themes doesn't work for you, you can find and download them online. Color-Themes Jetbrains Plugins (search for theme and you'll see a few there) Google (as always) As far as I know, themes that work for one Jetbrains IDE work for the rest too. So if you happen to find something labelled for IntelliJ or PhpStorm or whatever, it'll probably also work in WebStorm.
  9. fid will always hold the initialized value of v because nothing happens between the creation of the form and the assignment of the variable // form 2 form1 f1 = new form1(); fid = f1.v; // also note that if form1 is your startup form (ie: the form that's loaded up when you run your program), // then f1 won't contain a reference to that form. It contains a new form1 object that's completely separate from the currently opened forms. Updating f1.v after this won't change the value in fid because integers don't share a reference. The value in v is copied over to fid on assignment so you'd need to explicitly update fid to change its value. Example. int i = 0; int j = i; i = i + 1; // i contains 1 // j contains 0 not 1 j = i; // i still contains 1 // j contains 1 now as it's been updated If you need to share a reference, then you can use a class although this is probably not the ideal way to do it. Not sure if this is the behaviour you're looking for, but I wanted to mention it just in case. Another note. This code private int v; public void setupdate(int f) { v = f; } public int getupdate() { return v; } Is what a property does for you public int v { get; set; } // the above is shorthand for private int _v; public int v { get { return _v; } set { _v = value; } } // Which is basically the same thing you were doing with yout get/set methods // In fact, the compiler actually generates getter/setter methods for properties // http://stackoverflow.com/a/23102679/1765721
  10. Sure, but there's nothing wrong with learning C or C++ for your first language either. It's unclear if you're going to be learning one language or two for this course (the last part of this sentence implies one language but the title suggests two). C and C++ are two separate programming languages. Unless the course requires learning both C and C++, then you'll just want to focus on just one of them. Some people view C++ as C with some extra features and will recommend learning C first and then C++. This approach tends to cause people to learn C++ in a C style (although it depends on the learning material you're using). In my experience, most people these days consider that an outdated view of C++ and recommend treating them as completely different languages and to approach learning them differently. Ultimately we can't know how your course is expecting you to learn these languages (or if it even matters). Some general resources: StackOverflow: The Definitive C Book Guide and List StackOverflow: The Definitive C++ Book Guide and List LearnProgramming Subreddit: C++ FAQ Pluralsight Lynda
  11. Most likely. The product page lists the usage requirements at the bottom. Here it is quoted for you
  12. Here are some classes that you can look into to find what you need. They have a lot of useful methods for working with directories and files. Directory DirectoryInfo File FileInfo Path
  13. For client side the language to start with is JavaScript, however when it comes to server side development you have plenty of options. Pretty much every language has a web framework these days. So one option is to learn one of the popular options for a language you already know (if you know any at all). I would say that the most popular server side web languages these days are (in no particular order) JavaScript PHP Ruby Python Java C# But again, you have plenty of other options. Do you have any goals in learning web development (ex: landing a job, completing a project, etc) or do you just want to learn it for something to do?
  14. The code you're using adds a new tab, then puts the browser object in the SelectedTab. The tab you add won't be the selected tab so you need assign the new tab to the selected tab. Dim browse As New WebBrowser browse.Dock = DockStyle.Fill browse.Name = "wb" ' etc TabControl1.TabPages.Add(1, "page" & i) TabControl1.SelectedIndex = TabControl1.TabCount - 1 TabControl1.SelectedTab.Controls.Add(browse) Note that this will change the selected tab on the user which you may or may not want. Another option is to use the TabPages property instead of the SelectedTab property. This way you don't care what the selected tab is. Dim browse As New WebBrowser browse.Dock = DockStyle.Fill browse.Name = "wb" ' etc TabControl1.TabPages.Add(1, "page" & i) Dim lastTabIndex = TabControl1.TabCount - 1 TabControl1.TabPages(lastTabIndex).Controls.Add(browse) Alternatively you can create a TabPage object, assign it the required values and add the browser object to it, then add that object to the TabControl. This is the option I would use as I find it to be clearer. Dim browse As New WebBrowser browse.Dock = DockStyle.Fill browse.Name = "wb" ' etc Dim tab As New TabPage() tab.Name = i tab.Text = "page" & i ' etc tab.Controls.Add(browse) TabControl1.TabPages.Add(tab) ' Optionally select the tab with one of the following options (ie: by tab object or by index) TabControl1.SelectedTab = tab TabControl1.SelectedIndex = TabControl1.TabCount - 1 Also, in the future, please use code tags.
  15. If by "course" you mean "a course from your school", then just learn whatever language that the course uses. You'll go into the course with a head start which will hopefully make it easier for you and hopefully that means you'll get better grades. This way you're using your time most efficiently. There's no need to learn language X before you learn language Y so just go straight to the language you'll use. If you don't know what language the course uses, but know what platform the course targets (Android or iOS most likely), then learn the most commonly used language for that platform. Odds are it's what the class will use. So if the course focuses on Android then learn Java. If the courses focuses on iOS then learn Swift (and some Objective-C wouldn't hurt). If you have a choice on language, then I'd still go with the native language for the platform you're developing for. It's where most of the documentation and resources will be for the platform. It's can also be nice to be able to understand and use resources for the native language even if you're using something else to develop for the app (like C# and Xamarin for example).
  16. I can't say for sure which version the book supports or not, however the book tells you to install Unity 4.3 (viewed through amazon's preview) so it may only be up to that version. There doesn't appear to be a new edition to this book so probably not. Unity In Action was written for version 5.0 (they appear to be on 5.5.2 now) so that may be a better option. There are also more books written on Unity that are probably even more recent. I haven't read any unity books though so I can't give you any recommendations. Try to choose something that's both recent and well reviewed. That's about as good advice as I can give you if you want to buy a book. New versions may come with new ways of doing things so there's always a chance what you're using to learn will be out of date. The official documentation should always be up to date so be sure to use that as well. You can also look at docs/articles/tutorials/videos/etc for "What's New In Version X.Y.Z" to keep up with changes.
  17. One option is to list out all the different pieces of information you need to work with. These are what I gathered from your description. User Group Module Module Piece User Right Group Right Next decide what information you need to store for each item and the relationships between them. Then start mocking up tables (pencil/paper or whatever is fine, you don't need to start writing SQL yet). Each of these items may or may not end up as individual tables. You may find that one table can just be part of the columns in another table. Or you may find that one table can really be broken up into multiple tables. You may also find out that by working through the requirements, you will find the need to add additional tables that you didn't think of before or to store relationship information between tables. Lets take an example of converting these items into tables.
  18. It's usually good practice to dispose of any IDisposable objects. In this case, your MySqlConnection and MySqlCommand classes both implement IDisposable. You can either do this manually by calling the Dispose() method, or you can wrap them in using statements like so which automatically calls it for you. using (var connection = new MySqlConnection(connectionString)) { connection.Open(); var query = "... sql query here ..."; using (var command = new MySqlCommand(query, connection)) { // Add parameters if necessary. // They add protection against Sql Injection (https://en.wikipedia.org/wiki/SQL_injection). // Example) // command.Parameters.AddWithValue("@param", value); command.ExecuteNonQuery(); } } // Forgive any errors with using the MySql classes. I've done this stuff with Sql Server // but not MySql so I'm only going off a quick google search. If the MySql classes work in the same way, // disposing should clean up all the connections for you so it's easier to avoid errors like you're getting.
  19. Given what you say you know I would probably consider one of these for a desktop application C# (WPF) Java (JavaFx)
  20. Given how many non-programming aspects there can be to a game (artists, writers, voice actors, etc), it wouldn't be surprising if more money is spent in areas other than programming, especially if you're adding up all the other costs and putting it against just programming costs. And yes, existing game engines allow games to be made faster with less programmers. And yes, some teams might not even have a programmer on them because of the existence of these tools. The point is that even with all these factors, there are still a lot of programmers in the industry. People are still learning to program to become game developers. Companies are still hiring programmers. That's not going to change anytime soon. Whether or not you choose to learn programming to build games is up to you (as I assume this is ultimately what you're trying to decide on). If you don't have any interest in programming, then choose another aspect to learn. If you do, it's still an option.
  21. Programming is hardly useless in game development. Sure there's some stuff out there that allows you to make games without writing any code, but not everyone is going to choose to use them. Writing code will always give you more flexibility and control. Also just because you're not writing code with these tools, doesn't mean you're not still doing a form of programming. Your still working with events, logic, objects, etc which are all aspects of programming. For example, just because Unreal Engine has a visual scripting system and allows you to do a lot without writing any code, doesn't mean everyone is going to choose to use it over C++. As I mentioned above, using C++ will give you the most flexibility and control and using the visual scripting system is still a form of programming, it's just hiding the lines of code from you. Also keep in mind that all these tools that allow you to develop games with less coding, or no coding at all, have to be developed and maintained by people. Some people want to work on those tools rather than use them to develop games. tl;dr: The use of programming languages are a critical aspect of the game development industry and aren't going anywhere.
  22. Keep in mind that school assignment requirements don't always match industry best practices. In industry, it's a common practice to try and make your code as understandable as possible without comments. So in many cases, adding comments can often be unnecessary. However, in a school setting, choosing to leave them out may cause you to lose marks on an assignment if they are an explicit requirement. You might be able to argue to your professor that your code is clear and doesn't need comments, however I wouldn't risk it. That doesn't necessarily mean you need to comment every line of code, but don't remove them all either. A comment per "section", like straight_stewie said, is a good general approach. Adjust as you feel it's necessary. You can always ask your professor for clarification on what they consider "useful" vs "redundant/unnecessary". What you have may be similar to what they are looking for. Maybe not. Ultimately we can't know what your professor wants. There's a lot of tips on when it's good/bad to write comments in your code (ex: Google things like "when to comment code" and browse the results) but the advice won't necessarily apply to school assignments (or may just include advice that's too advanced for you right now). When in doubt, follow the professors requirements above all else, and ask them for help/clarification if necessary.
  23. While it can be unfortunate, in my experience it's not uncommon for an assignment to be given out before all the material to do the assignment is covered in class. It's possible you'll cover switch statements before the due date. You could always ask your teacher
  24. I don't have much experience with interactive tutorials for C#, so these may not be great resources, but they are the only one's I know of. .NET Academy Learn CS If/Once you've already got some programming experience, then Codin Game might interest you. For learning resources I recommend the following as they have a good selection of quality video courses to learn from. Microsoft Virtual Academy If you've never programmed before then C# Fundamentals for Absolute Beginners is a good place to start Pluralsight (get 3 free months when you join the free Visual Studio Dev Essentials program) They have a large library of courses on a variety of topics aimed at all levels and they have a C# path you can follow.
  25. I'm going to assume you mean Visual Studio. Visual Basic is a programming language, Visual Studio is an IDE to write and run code (among other things). Also, there is no Visual Studio 2016. There's a VS 2015 and a VS 2017 currently approaching release. I haven't used 2017 yet but I'll assume it's similar to 2015 when running command line apps. So the below information will probably apply either way. If my assumptions are incorrect, then sorry my mistake, and the below may not apply to you. If you're running the application from Visual Studio, and if running a C command line app is anything like running a .NET one, then the process when you run with a debugger is Open command line window Run application Close command line window if the program finishes You can stop it from closing in a couple ways If you're running in debug mode, you can set a breakpoint at the end of your main function You can also run your code without the debugger. There's a "Start Without Debugging" option. It'll keep the command line open with a "Press any key to continue..." to close it. You can also get user input at the end of your main method. This will keep the command line open until it receives input. You can also run the compiled executable directly from the command line
×