• Welcome to Final Fantasy Hacktics. Please login or sign up.
 
March 28, 2024, 05:32:41 pm

News:

Use of ePSXe before 2.0 is highly discouraged. Mednafen, RetroArch, and Duckstation are recommended for playing/testing, pSX is recommended for debugging.


Available for application programming

Started by nitwit, November 26, 2015, 09:02:06 pm

nitwit

I wouldn't mind writing a small application for my portfolio.  I'm most proficient with Java, but I've taken classes on C and Python, though I don't remember much of Python and I didn't go very in depth with C.  If anyone is interested please tell me exactly what behavior you want in your application, provide a sketch or image of the GUI if it is a GUI application, and provide any specifications and information about the data you want it to process.

Xifanie

Do you have any experience with wxWidgets/wxFormBuilder with C? I'm having issues :p
  • Modding version: PSX
Love what you're seeing? https://supportus.ffhacktics.com/ 💜 it's really appreciated

Anything is possible as long as it is within the hardware's limits. (ie. disc space, RAM, Video RAM, processor, etc.)
<R999> My target market is not FFT mod players
<Raijinili> remember that? it was awful

nitwit

No.  The C programming class was in the context of assembly language programming and console application.  Unfortunately the instructor gave no lectures and the class was mostly a waste.

What specific issues are you having?

Xifanie

How to "override" a class. I don't really know anything beyond that.
Basically, wxFormBuilder generates me classes to use (like giving a function for clicking a button), but I'm supposed to override them in another file in order to give them something to do... I don't know. ¯\(°_o)/¯

Also, I don't know what a class is yet, so don't mind me.
  • Modding version: PSX
Love what you're seeing? https://supportus.ffhacktics.com/ 💜 it's really appreciated

Anything is possible as long as it is within the hardware's limits. (ie. disc space, RAM, Video RAM, processor, etc.)
<R999> My target market is not FFT mod players
<Raijinili> remember that? it was awful

nitwit

November 26, 2015, 10:20:52 pm #4 Last Edit: November 26, 2015, 10:28:01 pm by nitwit
https://en.wikipedia.org/wiki/C_%28programming_language%29

QuoteC does not include some features found in newer, more modern high-level languages, including object orientation and garbage collection.


From what I understand, C doesn't contain classes.  Maybe you mean C++?

A class in Java - and presumably C# - is a collection of data (fields, parameters, and method variables) and logic (methods/functions and sometimes things like inner classes and other things you don't have to worry about yet) that describes the behavior of a particular type of object.

Let's say we have an application that schedules students in a university.  A Student object would contain fields:
  • Student ID

  • Name

  • Age

  • Major


It would also contain methods (called functions in some languages).  One method could print out all the data for a single Student object.  The logic for that method would be included in the Student object itself.  But why code this over and over again for every student?  That requires work, and we are lazy programmers.

Hence we have classes.

In java, we would write a class like this:

public class Student
{
//Fields for objects of type Student
//Fields follow this convention:
//visibility_modifer return_type identifer;

public String name;
//^this is publicly visible, returns a string, and is identified as "name".
//public fields aren't a good idea because anyone can write a program to interact with it and change the state of this field.

private int age;
//^this is private (only visible within this class - only methods in this class can modify it or access it),
        // it returns an int (a primitive, as opposed to an object), and it's called "age".

private String major;
//^note that String is an object in java.  Objects can be told apart from primitives because primitives are always lowercase.

//Next we have the constructors, which are intructions on how to create an object of this type (the type being Student).

public Student()//Note that these parenthesis are empty - no parameters are passed to the constructor.
{
name = "";//Empty string is not null in java.
age = 0;
major = "";
}

//You can have multiple contructors in a single class provided they have different parameters.
public Student (String nameParameter, int ageParameter, String majorParameter) //note that we declare the types of these parameters -
                                                                                                                     //they are a sort of temporary variable.
{
name = nameParameter;
age = ageParameter;
major = majorParameter;
//Normally you wouldn't use such clunky names to identify the paramters; this is just to illustrate a point.
}

//now we need a way to modify the private Student variables, age and major.  to do this we
        //need 2 types of methods: accessor/get methods and mutator/set methods.

//Below are two accessor or get methods.  They literally just return the value of an object variable.  Their usage will be discussed in the main method.
public int getAge()
{
return age;
}

public String getMajor()
{
return major;
}

//Below are two mutator or set methods, so called because they mutate or set the state of the fields/variables in the object.
public void setAge(int newAge)
{
age = newAge;
}

public void setMajor(String newMajor)
{
major = newMajor;
}

public void printDetails()
{
System.out.println("**Student Details**");
System.out.println("Name: " + name);
System.out.println("Age: " + getAge());
System.out.println("Major: " + getMajor() + "\n");
}

//Now that we have everything done for our student class, we can create a main method to test it out.  You can create a separate
        //main class, or you can put a main method within another class.  It really doesn't matter, just remember that your main method
        //is your entry point for your program.

public static void main(String[] args)
{
Student xifanie = new Student("Xifanie", 22, "Computer Science");
Student nitwit = new Student("Nitwit", 25, "Computer Information Systems");
Student dummy = new Student();

//Hmm, this is kinda lame.  Let's make it more interesting.
//Let's make an array of student objects.

Student[] cs160 = new Student[3];

//Let's add our three students to this array of Students.  Arrays start counting at 0 in Java

cs160[0] = xifanie;
cs160[1] = nitwit;
cs160[2] = dummy;

//Now let's add some stuff to the dummy entry
cs160[2].name = "Ramza";
cs160[2].setAge(18);
cs160[2].setMajor("l i t t l e  m o n e y");

//Now let's actually use this array.

for (int i = 0; i < 3; i++)
{
cs160[i].printDetails();
}
}
}


The output of the main method is this:
**Student Details**
Name: Xifanie
Age: 22
Major: Computer Science

**Student Details**
Name: Nitwit
Age: 25
Major: Computer Information Systems

**Student Details**
Name: Ramza
Age: 18
Major: l i t t l e  m o n e y



Object oriented programming isn't as straight forward or as easy to learn as structured or procedural programming, but it can be easier to use once you learn how to use it.  It's benefits lie in the simplicity of designing and implementing programs - you don't have to worry about naming conventions and really odd, obscure ways to get some function to work on all the members of a set of data, you only need to think about how they would actually work laid out as a series of interconnected and interacting objects.

Don't try to make sense of the code by itself, use an IDE or programmer's text editor with at least syntax highlighting.