Skip to content

Instantly share code, notes, and snippets.

View theArjun's full-sized avatar

Arjun Adhikari theArjun

View GitHub Profile
@theArjun
theArjun / Animal.java
Created January 14, 2019 15:31
Nested Interface Implementation
class Animal{
// Creating the interface inside class; nested interface.
interface Activity{
public default void move(){
System.out.println("Animal is moving.");
}
}
}
@theArjun
theArjun / Fibonacci.cpp
Last active January 14, 2019 04:35
Fibonacci By Recursion in Java
#include<iostream>
using namespace std;
int fibonacci(int);
int main(){
int number;
cout << "Enter how many elements you want to see in Fibonacci Series : ";
cin >> number;
@theArjun
theArjun / Factorial.cpp
Last active January 14, 2019 04:25
Factorial By Recursion in Java
#include<iostream>
using namespace std;
int factorial(int);
int main(){
int number, factorialOfNumber;
cout << "Enter a number you want to calculate factorial : ";
cin >> number;
@theArjun
theArjun / README.md
Last active January 20, 2019 15:13
Tower Of Hanoi by Recursion

Tower of Hanoi

How's it is solved ?

Tower Of Hanoi

Long steps ahead, but you're too intelligent to understand

Steps for Tower Of Hanoi

To know more :

@theArjun
theArjun / DisplayWithCommandLineArguments.java
Created January 11, 2019 12:57
Displays Files and Directories based on Command Line Arguments Passed
// Importing File class from Java io package.
// CLA in documentation refers to Command Line Argument.
import java.io.File;
// Creating a class named StringTest.
class StringTest{
public static void main(String[] args){
// To prevent any of the exception that may arise, I put the codes under try block.
try{
@theArjun
theArjun / CountsFileInDirectory.java
Created January 10, 2019 14:11
Java Program to Count and Display only Files of specified Directory
import java.io.File;
class CountsFile{
private static int count; // Count variable to count the no of files.
public static void count(){
count++; // Every time the method is envoked, count increases by 1.
}
public static int getCount(){
return count; // Getter for count.
}
@theArjun
theArjun / Calculate.java
Created December 19, 2018 09:20
Implementation of Copy Constructor in Java
// www.github.com/thearjun
class Calculate
{
int num1, num2;
Calculate(int number1, int number2)
{
num1 = number1;
num2 = number2;
@theArjun
theArjun / swapWithoutThirdVariable.py
Last active October 26, 2018 14:05
Swaps String Without Third Variable in Python
stringOne = str(input("Enter string one : "))
stringTwo = str(input("Enter string two : "))
print("\nBefore Swapping\n")
print("String One : %s"%(stringOne))
print("String Two : %s"%(stringTwo))
# Pre-Defined Method
# stringOne,stringTwo = stringTwo,stringOne
@theArjun
theArjun / Decimal To Binary.java
Last active October 20, 2018 12:33
Decimal Number To Binary Number System
class DecToBin{
public static void main(String[] args){
int dec = 64;
int bin=1,rem=0;// I assigned bin to 1 in this revision.
while(dec>1){ // I run the loop while dec is greater than 1 in this revision.
rem=dec%2;
bin=bin*10+rem;
dec=dec/2;
}
System.out.println("In Binary = "+bin);
@theArjun
theArjun / MultipleInheritance.cpp
Last active January 26, 2019 18:07
Diamond Inheritance
#include<iostream>
#include<string>
using namespace std;
class University{
private:
string uname;
public:
University():uname("unspecified"){}
University(string u):uname(u){}