Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions JAVA/StacksJava/StackApp.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package Java.StacksJava;

public class StackApp {
private long[] stackArray;
private int maxSize;
private int top;

public StackApp(int s) {
maxSize = s;
stackArray = new long[maxSize];
top = -1;
}

public void push(long i) {
stackArray[++top] = i;
}

public long peek() {
return stackArray[top];
}

public long pop() {
return stackArray[top--];
}

public boolean isEmpty() {
return (top == -1);
}

public boolean isFull() {
return (top == maxSize - 1);
}

public void display() {

for (int i = 0; i <= top; i++) {
System.out.print(stackArray[i] + " ");
}
System.out.println("");

}
}
33 changes: 33 additions & 0 deletions JAVA/StacksJava/Stacks.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package Java.StacksJava;

public class Stacks {

public static void main(String[] args) {
StackApp my_stack = new StackApp(10);

my_stack.push(10);
my_stack.push(20);
my_stack.push(40);
my_stack.push(30);
System.out.println(my_stack.peek());
my_stack.display();
my_stack.push(60);
my_stack.push(80);
my_stack.display();
System.out.println(my_stack.pop());
my_stack.display();
my_stack.push(100);
my_stack.push(50);
my_stack.push(90);
my_stack.display();

while (!my_stack.isEmpty()) {
long value = my_stack.pop();
System.out.print(value);
System.out.print(" ");

}
System.out.println("");
}

}
99 changes: 99 additions & 0 deletions Python/downloadsManager.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import os
import shutil
import platform

# function to run on linux


def runLinux():
print("on Linux")
linuxUsername = str(os.getlogin())
linuxDirectory = "/home/" + linuxUsername + "/Downloads"
os.chdir(linuxDirectory)

for f in os.listdir(linuxDirectory):
fileSource = str(os.getcwd()) + "/" + str(f)
fileTypeSplitList = list(os.path.splitext(f))
fileType = fileTypeSplitList[1]
if(fileType == '.torrent'):
if not (os.path.isdir("Torrents")):
os.mkdir("Torrents")
shutil.move(fileSource, os.getcwd() + "/" + "Torrents")
elif(fileType == '.mp3' or fileType == '.wav'):
if not (os.path.isdir("Music")):
os.mkdir("Music")
shutil.move(fileSource, os.getcwd() + "/" + "Music")
elif(fileType == '.mp4' or fileType == '.wmv' or fileType == '.ogg'):
if not (os.path.isdir("Videos")):
os.mkdir("Videos")
shutil.move(fileSource, os.getcwd() + "/" + "Videos")
elif(fileType == '.deb'):
if not (os.path.isdir("Softwares")):
os.mkdir("Softwares")
shutil.move(fileSource, os.getcwd() + "/" + "Softwares")
elif(fileType == '.tar' or fileType == '.7z' or fileType == '.rar' or fileType == '.zip'):
if not (os.path.isdir("Softwares")):
os.mkdir("Softwares")
shutil.move(fileSource, os.getcwd() + "/" + "Softwares")
elif(fileType == '.png' or fileType == '.jpg' or fileType == '.jpeg' or fileType == '.gif'):
if not (os.path.isdir("Images")):
os.mkdir("Images")
shutil.move(fileSource, os.getcwd() + "/" + "Images")
elif(fileType == '.pdf'):
if not (os.path.isdir("PDF_Documents")):
os.mkdir("PDF_Documents")
shutil.move(fileSource, os.getcwd() + "/" + "PDF_Documents")

# function to run on windows


def runWindows():
print("on windows")
windowsUsername = str(os.getlogin())
windowsDirectory = "C:/Users/" + windowsUsername + "/Downloads"
os.chdir(windowsDirectory)

for f in os.listdir():
file_source = str(os.getcwd()) + "\\" + str(f)
file_source = str(file_source.replace("\\", "/"))
splitList = list(os.path.splitext(f))
file_type = splitList[1]

if(file_type == '.torrent'):
if not (os.path.isdir("Torrents")):
os.mkdir("Torrents")
shutil.move(file_source, os.getcwd() + "\\" + "Torrents")

elif(file_type == '.mp3'):
if not (os.path.isdir("Music")):
os.mkdir("Music")
shutil.move(file_source, os.getcwd() + "\\" + "Music")

elif(file_type == '.mp4'):
if not (os.path.isdir("Videos")):
os.mkdir("Videos")
shutil.move(file_source, os.getcwd() + "\\" + "Videos")

elif(file_type == '.zip' or file_type == '.rar'):
if not (os.path.isdir("Archives")):
os.mkdir("Archives")
shutil.move(file_source, os.getcwd() + "\\" + "Archives")

elif(file_type == '.exe'):
if not (os.path.isdir("EXE")):
os.mkdir("EXE")
shutil.move(file_source, os.getcwd() + "\\" + "EXE")


def runMac():
print("Since i cannot afford an apple computer to implement the function ,u cannot manage your downloads :-(")


operatingSystem = platform.system()

if(operatingSystem == 'Linux'):
runLinux()
elif(operatingSystem == 'Windows'):
runWindows()
else:
runMac()