You are on page 1of 32

<<<<< Our Concept is >>>>>

1 - making calculator by using


notepad
2 - making timer watch by using
notepad
3 - making quiz game by using
motepad
4 - making brain game by using
notepad

5 - making batch antivirus by


using notepad

Lesson 4 th

making brain game by using


notepad by suraj singh
this is a fig of brain games

Below given codes ------@echo off


setlocal enabledelayedexpansion
title Noughts and crosses 2

:main
call :titleScreen
if "%EXIT%"=="1" exit /b
call :firstSetup

:main_Loop
call :resetBoard
call :gameLoop
call :endGameScreen %win%
if /i %rematch%==Y (
goto main_Loop
)
exit /b

:titleScreen
echo Welcome to Noughts and Crosses.
echo.
echo.
echo Type EXIT to quit the game.

echo.

:askP1Type
set p1Type=
set /p p1Type="Player 1 - Human or computer? [H/C] - "
if /i "!p1Type!"=="C" goto askP2Type
if /i "!p1Type!"=="H" goto askP2Type
if /i "!p1Type!"=="EXIT" (
set EXIT=1
exit /b
)
goto askP1Type

:askP2Type
set p2Type=
set /p p2Type="Player 2 - Human or computer? [H/C] - "
if /i "!p2Type!"=="C" exit /b
if /i "!p2Type!"=="H" exit /b
if /i "!p2Type!"=="EXIT" (
set EXIT=1
exit /b
)

goto askP2Type

:firstSetup
set p1Score=0
set p2Score=0
set turn=
set p1Char=X
set p2Char=O
set p1Score=0
set p2Score=0
set NL=^

::winList contains all the possible winning lines, separated by the new line
character.
set winList=1 2 3 !NL! 4 5 6 !NL! 7 8 9 !NL! 1 4 7 !NL! 2 5 8 !NL! 3 6 9 !NL! 1 5 9
!NL! 3 5 7
exit /b

:ResetBoard
for /l %%I in (1,1,9) do (

set G%%I=%%I
)
if "%turn%"=="" (
set /a turn=%random% %% 2 + 1
) else (
set /a turn= 3 - %turn%
)
set turnCount=0
set availableMoves=123456789
set errorMessage=
set win=0
exit /b

:gameLoop
set /a otherTurn= 3 - %turn%
if /i "!p%turn%Type!"=="H" (
call :humanTurn
) else (
call :computerTurn %turn% !p%turn%Char! !p%otherTurn%Char!
)
set /a turnCount+=1
set availableMoves=!availableMoves:%move%=!

if NOT %win%==0 exit /b


if %turnCount%==9 exit /b
set /a turn= 3 - %turn%
goto GameLoop

:humanTurn
call :displayGrid
echo.
echo.%infoMessage%
set infoMessage=
set move=
set /p move= Player %turn%'s turn. Enter the number of your move [1-9] if !move! lss 1 (
set infoMessage=Invalid move, enter a number between 1 and 9.
goto humanTurn
)
if !move! gtr 9 (
set infoMessage=Invalid move, enter a number between 1 and 9.
goto humanTurn
)
if NOT "!G%Move%!"=="!Move!" (
set infoMessage=That move has already been made, choose another.

goto humanTurn
)
set G%move%=!p%turn%Char!
call :CheckWin %turn% !p%turn%Char!
exit /b

:computerTurn

set move=
for /f "tokens=1-3 delims= " %%I in ("!winList!") do (
if "!G%%I!!G%%J!!G%%K!"=="%2%2%%K" (
set move=%%K
)
if "!G%%I!!G%%J!!G%%K!"=="%2%%J%2" (
set move=%%J
)
if "!G%%I!!G%%J!!G%%K!"=="%%I%2%2" (
set move=%%I
)

if NOT "!move!"=="" (
set G!move!=%2

set win=%1
exit /b
)

for /f "tokens=1-3 delims= " %%I in ("!winList!") do (


if "!G%%I!!G%%J!!G%%K!"=="%3%3%%K" (
set move=%%K
)
if "!G%%I!!G%%J!!G%%K!"=="%3%%J%3" (
set move=%%J
)
if "!G%%I!!G%%J!!G%%K!"=="%%I%3%3" (
set move=%%I
)

if NOT "!move!"=="" (
set G!move!=%2
exit /b
)
)

set /a moveGuess= %random% %% ( 9 - %turnCount% )


set move=!availableMoves:~%moveGuess%,1!
set G%move%=!p%turn%Char!
exit /b

:displayGrid
cls
echo.
echo
echo
echo
echo
echo
echo
echo

^| ^|
%G1% ^| %G2% ^| %G3%
------------%G4% ^| %G5% ^| %G6%
------------%G7% ^| %G8% ^| %G9%
^| ^|

exit /b

:checkWin
for /f "tokens=1-3 delims= " %%I in ("!winList!") do (
if "!G%%I!!G%%J!!G%%K!"=="%2%2%2" (
set win=%1
exit /b

)
)
set win=0
exit /b

:endGameScreen
if NOT %win%==0 (
set /a p%win%Score+=1
)
call :Displaygrid
echo.
echo.
if %win% gtr 0 (
echo Player %win% wins^!
) else (
echo It's a draw^!
)
echo.
echo.
echo

Current Scores

echo

--------------

echo Player 1 Score - %p1Score%

Player 2 Score - %p2Score%

echo.
set rematch=
set /p rematch="Would you like a rematch? [Y/N] - "
if /i "!rematch!"=="Y" exit /b
if /i "!rematch!"=="N" (
exit /b
) else (
goto endGameScreen
)

And now set this to.bat

Lesson 5 th

making batch antivirus by using


notepad by suraj singh
this a fig. of batch antivirus

Beow given codes -------@echo off


color cb
title Batch Antivirus
cls

echo ===============
echo [ Batch-Master]
echo ===============
echo If There's no message ,You are protected.
set /p a=Enter a batch file to scan:
for /f %%x in (
'findstr /i /m "virus r.i.p byebye HaHaHa Hacked Hack" %a%.bat'
) do (
if /i %%x equ %a%.bat (
for /f %%z in (
'findstr /i /b /m "tskill del copy shutdown ipconfig ren reg" %a%.bat'
) do (
if /i %%z equ %a%.bat (
cls
echo Virus Detected!!
del %a%.bat
echo %a%.bat was deleted....
pause >nul
)
)
)
)

pause >nul

and then save it for typing this....


"antivirus.bat"..........

Lesson-1 st
Making calculator by using
notepad by suraj singh
This is a fig. of calculator

Below some codes to make calculator ---------

@echo off
title Batch Calculator by Techies
color 0c
:top
echo

echo -Welcome to Batch Calculator by Techies Blogspot !echo


echo Enter your Calculations
echo.
set /p sum=
set /a ans=%sum%
echo.
echo = %ans%
echo
pause
cls
echo Previous Answer: %ans%
goto top
pause
exit

And Save as "Calc.bat"

Lesson -2 nd
Making timer watch by using notepad
By suraj singh
This is a fig. of timer watch

Below some codes to make a timer watch---@echo off


Title OnlineCmag-Clock
color b
cls
: Clock
cls

echo Current Date: %date%


echo .............
echo .............
echo Current Time: %time%
goto Clock

Now Save this file with a .bat extension


i.e something like -Clock.bat .

Lesson -3 rd

making quiz game by using


motepad- by suraj singh
this is a fig. of quiz game

Below given codes ----------------@echo off

title SHOCKING QUIZ


echo ------------------echo EAT Games present's

echo ------------------echo.
echo SHOCKING QUIZ
echo by sahil
color 2
echo.
pause
cls

:one
color 3
echo WeLcOmE
echo.
echo TO start game type A and press enter.
echo.
echo To see instructions type B and press enter.
echo.
echo TO quit type C and press enter.
echo.
set /p y=What you want to do?:
if %y%== a goto two
if %y%== b goto three

if %y%== c goto quit


goto quit

:three
cls
color e
echo INSTRUCTIONS
echo.
echo 1)no cheating
echo.
echo 2)five question will come to you,every right answer will unlock second
question.
echo.
echo 3)if any wrong answer you will be out of the game.
echo.
echo 4)when a question comes to you their are four options (A,B,C and D)
echo if answer is 'A' of given question then type 'A' and press enter.
echo.
pause
cls
echo To play game type 1 and press enter
echo.
set /p num=COMMAND:

if %num%== 1 goto two


goto quit

:two
cls
color f
echo Are you ready to play.....
echo.
pause
cls
echo 1)When Neil Armstrong landed on moon which foot did he step first?
echo.
echo a)Left
echo b)Right
echo c)Both legs at a time
echo d)He dosent have legs
echo.
set/p ans=ANSWER:
if %ans%== a goto fourth
if %ans%== b goto wrong
if %ans%== c goto wrong
if %ans%== d goto wrong

goto quit

:wrong
cls
color 4
echo SORRY!! you have given wrong answer.
pause
goto quit

:fourth
echo.
echo CONGRATULATION..
echo You have unlocked second question
echo.
pause
cls
echo 2)Who invented FACEBOOK?
echo.
echo a)Bill Gates
echo b)Steve Jobs
echo c)Mark Zukerberg
echo d)Jhon Zukerberg

echo.
set/p ans=ANSWER:
if %ans%== a goto wrong
if %ans%== b goto wrong
if %ans%== c goto fifth
if %ans%== d goto wrong
goto quit

:fifth
echo.
echo CONGRATULATION..
echo You have unlocked third question
echo.
pause
cls
echo 3)Which was first advanced humanoid robo?
echo.
echo a)Asimo
echo b)Electro
echo c)NAO
echo d)Humbo
echo.

set/p ans=ANSWER:
if %ans%== a goto wrong
if %ans%== b goto sixth
if %ans%== c goto wrong
if %ans%== d goto wrong
goto quit

:sixth
echo.
echo CONGRATULATION..
echo You have unlocked fourth question
echo this is slightly hard
echo.
pause
cls
echo 4)What was the name of first plane made by Wright Brothers?
echo.
echo a)Eagle
echo b)Air Winger
echo c)Wright's
echo d)Flyer
echo.

set/p ans=ANSWER:
if %ans%== a goto wrong
if %ans%== b goto wrong
if %ans%== c goto wrong
if %ans%== d goto seventh
goto quit

:seventh
cls
echo.
echo CONGRATULATION..
echo.
echo You have unlocked last question of the game
echo.
echo.You are one step away from being WINNER.
echo.
echo are you READY TO PLAY...
echo.
pause
cls
echo 5)Which is one and only one mammal that lay egg?
echo.

echo a)Autumpus
echo b)Playtipus
echo c)Whale
echo d)Congo
echo.
set/p ans=ANSWER:
if %ans%== a goto wrong
if %ans%== b goto correct
if %ans%== c goto wrong
if %ans%== d goto wrong
goto quit

:correct
cls
start sahil.jpg
pause
echo Cerdits...
echo.
echo thank you for playing this game
echo.
echo Game made by Sahil Kore
echo For any details email me on 'sahilkore@gmail.com'

echo.
echo.
pause
goto quit

and save it to .bat

Programming & coding


------------

By Suraj Singh

In echo codes
-------------echo-------------@
----------------@
------------------echo.-------------------------------@
--------------------------------------------echo----------------------@
--------echo.----------------------------------------------------------------------@
------------------------------------------------echo---------------------------------------@

My Web Adresses Is >>>>>


Yahoo mail : suraj.singh981@yahoo.com
Gmail : kumarsurajsingh023@gmail.com

Fb : facebook.com/surajkeshr
Website : Surajsin.Weebly.Com

You might also like