-4
我有一個簡單的DOS克隆,我稱之爲JDOS或Jacob的DOS,我想知道它缺少什麼?需要添加什麼
如果你正在嘗試它,有一個命令沒有列出(故意使用)admin
。密碼是空白的,所以只需按回車即可。
我是一個Python初學者程序員,所以請讓它成爲一個挑戰,但不要太難。
這裏的腳本:
def jdos1():
print " Boot JDOS.exe?"
answer = raw_input(" [y] or [n]").lower()
if answer == "y" or answer == "[y]":
import time
time.sleep(1)
print " Welcome to JDOS"
time.sleep(1)
print " Type cmds for a list of all avalible commands"
def jdos2():
cmd = raw_input().lower()
if cmd == "exit":
print " Exiting JDOS"
time.sleep(1)
elif cmd == "info":
print "JDOS Script 1.4.0. Created by Jacob Snyder [email protected]"
jdos2()
elif cmd == "ver":
print "JDOS 1.4.0"
jdos2()
elif cmd == "upd":
print ""
jdos2()
elif cmd =="admin":
password = raw_input(" Please enter your admin password.")
def admin():
if password == "".lower():
print " rebooting in admin mode"
time.sleep(1)
print " Welcome to JDOS-Admin"
def admin2():
cmd = raw_input().lower()
if cmd == "exit":
print " Exiting JDOS-Admin"
time.sleep(3)
elif cmd == "password":
print " Your password is, %s" % (password)
admin2()
elif cmd == "admin":
print " Already booted in admin mode"
admin2()
elif cmd == "format":
print " Formatting D:"
time.sleep(3)
elif cmd == "ver":
print " JDOS 1.4.0"
admin2()
elif cmd == "info":
print " JDOS-Admin Script 1.4.0. Created by Jacob Snyder [email protected]"
admin2()
elif cmd == "upd":
print ""
admin2()
elif cmd == "date":
from datetime import datetime
now = datetime.now()
print ' %s/%s/%s' % (now.month, now.day, now.year)
admin2()
elif cmd == "add":
inp1 = float(raw_input(" Enter 1st integer:"))
inp2 = float(raw_input(" Enter 2nd integer:"))
oup1 = inp1 + inp2
print " %s+%s=%s" % (inp1, inp2, oup1)
admin2()
elif cmd == "subtract":
inp1 = float(raw_input(" Enter 1st integer:"))
inp2 = float(raw_input(" Enter 2nd integer:"))
oup1 = inp1 - inp2
print " %s-%s=%s" % (inp1, inp2, oup1)
admin2()
elif cmd == "multiply":
inp1 = float(raw_input(" Enter 1st integer:"))
inp2 = float(raw_input(" Enter 2nd integer:"))
oup1 = inp1 * inp2
print " %sx%s=%s" % (inp1, inp2, oup1)
admin2()
elif cmd == "divide":
inp1 = float(raw_input(" Enter 1st integer:"))
inp2 = float(raw_input(" Enter 2nd integer:"))
oup1 = inp1/inp2
print " %s/%s=%s" % (inp1, inp2, oup1)
admin2()
elif cmd == "cmds" or cmd == "cmd":
print " cmds, date, add, subtract, multiply, divide, password, admin, format, ver, info, upd, exit"
admin2()
else:
print " Invalid command"
admin2()
admin2()
elif password == "cancel":
print " Canceling"
else:
print " Incorrect password"
admin()
elif cmd == "secret":
print " Congrats on finding the secret, Heres a cookie! . ____ ./- . \ |, - * | .\____/"
jdos2()
elif cmd == "date":
from datetime import datetime
now = datetime.now()
print ' %s/%s/%s' % (now.month, now.day, now.year)
jdos2()
elif cmd == "add":
inp1 = float(raw_input(" Enter 1st integer:"))
inp2 = float(raw_input(" Enter 2nd integer:"))
oup1 = inp1 + inp2
print "%s+%s=%s" % (inp1, inp2, oup1)
jdos2()
elif cmd == "subtract":
inp1 = float(raw_input(" Enter 1st integer:"))
inp2 = float(raw_input(" Enter 2nd integer:"))
oup1 = inp1 - inp2
print "%s-%s=%s" % (inp1, inp2, oup1)
jdos2()
elif cmd == "multiply":
inp1 = float(raw_input(" Enter 1st integer:"))
inp2 = float(raw_input(" Enter 2nd integer:"))
oup1 = inp1 * inp2
jdos2()
elif cmd == "divide":
inp1 = float(raw_input(" Enter 1st integer:"))
inp2 = float(raw_input(" Enter 2nd integer:"))
oup1 = inp1/inp2
print "%s/%s=%s" % (inp1, inp2, oup1)
jdos2()
elif cmd == "cmds" or cmd == "cmd":
print " cmds, date, add, subtract, multiply, divide, info, upd, ver, exit"
jdos2()
else:
print " Invalid command"
jdos2()
jdos2()
elif answer == "n":
print ""
else:
print " Invalid command"
jdos1()
jdos1()
這個問題是非常模糊的,你給了我們很多的代碼來閱讀。你爲什麼覺得缺少一些東西?你期望什麼行爲?你看到了什麼? – jcolemang
我投票結束這個問題作爲題外話,因爲它不是一個關於編程的問題。 – smarx