ZPrime Documentation


Class

To start programming, you will need to setup a class. Currently you can only make one class, and you cannot have multiple files interacting with each other.

To setup a class, you simply do
public class (FileName) { 

}

like Java, you program inside of the class, not outside. The compiler will throw you an error if you do not have a class.

Make sure that you spell your class's name exactly as the file name, with capitals. In future versions of the compiler this will not be an issue.


Main method

For the compiler to execute your code you will need a main method. To create a main method, it is quite simply
public static v0 main() { 

}

the "main" remains the same for all classes, it is not based off the class name

Print

As the name suggests, this standard method prints to the console. The print method can take in integers, floats, doubles, longs, booleans, and strings.
The print method is called by
print(obj);

You can concatinate things inside of the print method
print(x+" "+y), this will print out the value of x, a space, and the the value of y

Data types

Data types are a specification of what type a variable is. Here is a table of data types

Data type Definition Example
int a round number (-1,0,1) not (-0.5, 0.1, 1.5) int x = 5;
float a round number or broken number (-1,0,1), (-0.5, 0.1, 1.5) float x = 5.54f;
double a round number or broken (-1,0,1),(-0.5, 0.1, 1.5) double x = 900.9;
long a round number (-1,0,1) not (-0.5, 0.1, 1.5) long x = 5000000000000000;
boolean a true or false value boolean x = true;
string a text value, or a string of character string x = "this is a string";

If statements

If statements are crucial for programming, they allow you to execute code at specific events.

ZPrime's if statements are the same as any other programming languages, you declare it by saying if

you have the argument(s) in round brackets, and then you declare what should happen if the statement is true with an opening curly bracket and end the statement with a closing curly bracket

if (x >= 5) { print("x is greater than or equal to 5"); }

In the table below are signs that you can use in if statements

Symbol(s) Definition Example
== If one value is equal to another value if (x == y) { print("x equals y"); }
!= If one value does not equal to another if (x != y) { print("x does not equal y"); }
>= If one value(number) is greater than or equal to another value(number) if (x >= y) { print("x greter than or equal to y"); }
<= If one value(number) is less than or equal to another value(number) if (x <= y) { print("x is less than or equal y"); }
> If one value(number) is greater than another value(number) if (x > y) { print("x is greater than y"); }
< If one value(number) is less than another value(number) if (x < y) { print("x is less than equal y"); }
|| if x or if y if (x < y || y >= 20) { print(x+" "+y); }
&& if x and if y if (x < y && y >= 20) { print(x+" "+y); }

Input

The input method in ZPrime will only be recognized of the variable data type is a string.

If a string's value is set as input(); then the code will stop and wait for an input from the user.

The reason the input method is only recognized for a string is because strings cover all data types.

Changing from a string to a number or boolean or vice versa will be soon added to the compiler.

Here is an example of the input method:

string input = input();
if (input == "hello") {
print("hello")
}


While loops

While loops repeat the code inside until the condition is false.

Here is a code snipet, the condition is the statement in the brackets

while (true) {
print("Hello World");
}

This code will print "Hello World" infinitely until the program is closed.


Waits

As suggested by the name, waits make the program wait in milliseconds.

Waits take in an integer as their parameter, the compiler will throw you an error if it is the incorrect type or if the number is below 0

wait(100);

this waits 100 milliseconds.


That is everything for now.



Home

awewsomegamer