Taught by Ms. Taricco, Computer Science (CS) involves learning the computer programming and the problem-solving skills necessary to succeed in the field. As a student in the advanced section, I work on my independent CS project and create advanced algorithms to solve problems.
Cryphor is a 3D capture-the-flag game I am developing in Unity (C#) with two other students (Medhansh Choudhury & Anshu Adiga). Players on opposing teams try to reach the other side without getting their flag broken by other players. The game is still in development, but you can view a video of our progress here.
import java.util.Scanner;
public class Chmod {
public static void main (String[] args) {
System.out.println("Welcome to the CHMod Converter! " +
" \nThis will only take numbers mod 8 to ensure that
no invalid numbers are inputted. "
+ "\nFor special permissions, it is taken mod 5.");
Scanner input = new Scanner(System.in);
System.out.print("Enter special permissions #: ");
int a = (input.nextInt()) % 5;
System.out.print("Enter read permissions #: ");
int b = (input.nextInt()) % 8;
System.out.print("Enter write permissions #: ");
int c = (input.nextInt()) % 8;
System.out.print("Enter execute permissions #: ");
int d = (input.nextInt()) % 8;
input.close();
String owner = convertBinary3(b);
String group = convertBinary3(c);
String others = convertBinary3(d);
boolean readOwner = owner.charAt(0) == '1';
boolean writeOwner = owner.charAt(1) == '1';
boolean executeOwner = owner.charAt(2) == '1';
boolean readGroup = group.charAt(0) == '1';
boolean writeGroup = group.charAt(1) == '1';
boolean executeGroup = group.charAt(2) == '1';
boolean readOthers = others.charAt(0) == '1';
boolean writeOthers = others.charAt(1) == '1';
boolean executeOthers = others.charAt(2) == '1';
System.out.print(owner + " " + group + " " + others + " and ");
OwnerTree(readOwner, writeOwner, executeOwner, a);
GroupTree(readGroup, writeGroup, executeGroup, a);
OthersTree(readOthers, writeOthers, executeOthers, a);
}
public static String convertBinary3(int b) {
String owner;
if (b == 1) {
owner = "00" + Integer.toBinaryString(b);
}
else if (b < 4 && b > 1) {
owner = "0" + Integer.toBinaryString(b);
} else if (b == 0) {
owner = "000";
}
else {
owner = Integer.toBinaryString(b);
}
return owner;
}
public static void OwnerTree(boolean read, boolean write,
boolean execute, int SpecialMod) {
if (read) {
System.out.print("r");
} else {
System.out.print("-");
}
if (write) {
System.out.print("w");
} else {
System.out.print("-");
}
if (execute) {
if (SpecialMod == 1) {
System.out.print("s ");
} else {
System.out.print("x ");
}
} else {
System.out.print("- ");
}
}
public static void GroupTree(boolean read, boolean write,
boolean execute, int SpecialMod) {
if (read) {
System.out.print("r");
} else {
System.out.print("-");
}
if (write) {
System.out.print("w");
} else {
System.out.print("-");
}
if (execute) {
if (SpecialMod == 2) {
System.out.print("s ");
} else {
System.out.print("x ");
}
} else {
System.out.print("- ");
}
}
public static void OthersTree(boolean read, boolean write,
boolean execute, int SpecialMod) {
if (read) {
System.out.print("r");
} else {
System.out.print("-");
}
if (write) {
System.out.print("w");
} else {
System.out.print("-");
}
if (execute) {
if (SpecialMod == 4) {
System.out.print("t ");
} else {
System.out.print("x ");
}
} else {
System.out.print("- ");
}
}
}
Earlier in the year, I worked on an algorithm called Chmod, a Java parser that takes an octal input and returns the permissions of the file. The algorithm is based on the Unix file permissions system and was simulated in Java. You can preview the code for the project here and download it here.