Skip to content

Instantly share code, notes, and snippets.

View LaurentiuGabriel's full-sized avatar
🚀
Working on an exciting project!

Laurentiu Raducu LaurentiuGabriel

🚀
Working on an exciting project!
View GitHub Profile
@LaurentiuGabriel
LaurentiuGabriel / learn_python.py
Created April 2, 2023 11:50
Python in 99 seconds
# Variables
x = 5
y = 1.5
name = "John"
is_active = True
# Conditionals
if x > y:
print("x is greater than y")
elif x < y:
@LaurentiuGabriel
LaurentiuGabriel / Tower_of_Hanoi.java
Created August 7, 2022 15:15
Tower of Hanoi YouTube Challenge
public class Tower_of_Hanoi {
static void towerOfHanoi(int n, char first_rod, char third_rod, char second_rod){
if (n == 1) {
System.out.println("Move disk 1 from rod " + first_rod + " to rod " + third_rod);
return;
}
towerOfHanoi(n - 1, first_rod, second_rod, third_rod);
System.out.println("Move disk " + n + " from rod " + first_rod + " to rod " + third_rod);
towerOfHanoi(n - 1, second_rod, third_rod, first_rod);
public enum ObjectOrientedProgrammingLanguages {
JAVA,
PYTHON,
CPP
}
public class App {
public static void main(String[] args) {
System.out.println(ObjectOrientedProgrammingLanguages.JAVA);
for(ObjectOrientedProgrammingLanguages oopLanguages : ObjectOrientedProgrammingLanguages.values()){
System.out.println(oopLanguages);
}
}
}
class OuterClass {
void printMessage(){
System.out.println("This is the outer class!");
}
class InnerClass {
void print(){
System.out.println("This is the inner class!");
}
}
}
import java.util.Scanner;
interface Event {
String message = "An event has been triggered!";
void printMessage();
}
public class App {
public static void main(String[] args) {
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;
public class App {
public static void main(String[] args) throws IOException {
File file = new File("text");
Scanner scanner = new Scanner(file);
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
public class App {
public static void main(String[] args) {
//Example of checked exception
File file = new File("C:\\randomname.txt");
try {
import java.util.Objects;
public class Laptop extends Computer {
private String manufacturer;
public String getManufacturer() {
return manufacturer;
}
public class App {
public static void main(String[] args) {
Laptop laptop = new Laptop();
laptop.setManufacturer("HP");
System.out.println(laptop);
}
}