Skip to content

Instantly share code, notes, and snippets.

@ARamy23
Created October 17, 2017 23:04
Show Gist options
  • Save ARamy23/8a90d5e494059a8ed7f72fcc26771074 to your computer and use it in GitHub Desktop.
Save ARamy23/8a90d5e494059a8ed7f72fcc26771074 to your computer and use it in GitHub Desktop.
Making the famous Tower of Hanoi game , will feature those ISA , num of moves done , optimum no. of moves , return to last move played
<html>Simple <b>Java</b> application that includes a class with <code>main()</code> method</html>
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="EntryPointsManager">
<entry_points version="2.0" />
</component>
<component name="ProjectKey">
<option name="state" value="project://e2804f05-5315-4fc6-a121-c522a6c26470" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/TowerOfHanoi.iml" filepath="$PROJECT_DIR$/TowerOfHanoi.iml" />
</modules>
</component>
</project>
<template>
<input-field default="com.company">IJ_BASE_PACKAGE</input-field>
</template>
package com.RMSCourse.Projects.TowerOfHanoi;
import java.util.Scanner;
import java.util.Stack;
public class Main
{
public static void greetings(String name)
{
if(name.equalsIgnoreCase("Mahmoud Soubih"))
System.out.println("Welcome ya 7ag :D!");
else
System.out.println("Welcome, " + name+ " !");
}
public static void displayColumn()
{
String columns = "\t*\t\t\t*\t\t\t*";
for(int i = 0; i < 8 ; i++)
{
System.out.println(columns);
}
System.out.print(" ****************************");
}
public static void makeTower(Stack<String> tower , int towerHeight/*Difficulty*/)
{
for(int currentFloor = 0 ; currentFloor < towerHeight ; currentFloor++)
{
//enter empty elements in the stack to make sure we have places to hold spaces and #s
for(int i = 0 ; i < towerHeight ; i++)
{
tower.add("");
}
for(int spaces = currentFloor ; spaces < towerHeight ; spaces++ )
{
tower.set(currentFloor, " ");
}
for(int currentTile = 1; currentTile <= (currentFloor * 2) - 1 /*to make sure its odd */; currentTile++)
{
//supposed to make a pyramid here but having a problem with concatenating it with the spaces
}
}
}
public static void selectAndMoveTile(int tileNumber)
{
/*
should be a code here which select the tower and move the upper tileset to desired tower
*/
}
public static void main(String[] args)
{
Scanner inString = new Scanner(System.in);
// System.out.print("Hello , Please enter your name: ");
// greetings(inString.nextLine());
displayColumn();
}
}
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment