Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import datetime
- #To enable us to set the date
- class Tesj:
- def __init__(self,TesjID):
- self.__TesjID = TesjID
- self.__questions = []
- self.__NumberOfQuestions = 0
- self.__MaxMarks = 0
- self.__Level = None
- self.__DateSet = datetime.datetime.now()
- def DesignTesj(self):
- #Set level for Tesj
- while True:
- level = input("Set Tesj level (A, S, G):")
- if level.upper() in ["A","S","G"]:
- self.__level = level
- break
- else:
- print("Wrong level code")
- while True:
- if self.__NumberOfQuestions < 10:
- yn = input("Do you wish to add a question?")
- if yn.upper() == "Y":
- #Generate question id based on Tesj id and question number
- newQID = self.__TesjID + str(self.__NumberOfQuestions)
- #Create question object
- newQuestion = Question(newQID)
- #Setup the question
- newQuestion.setQuestion()
- #Add the marks to the max marks
- self.__MaxMarks += newQuestion.GetMarks()
- #Link the question to my list (array)
- self.__questions.append(newQuestion)
- self.__NumberOfQuestions += 1
- else:
- break
- else:
- break
- def PrintTesj(self):
- for question in self.__questions:
- print(question.getQuestion())
- def PrintAnswers(self):
- for question in self.__questions:
- print(question.GetAnswer())
- class Question:
- def __init__(self,QuestionID):
- self.__QuestionID = QuestionID
- self.__QuestionText = ""
- self.__Answer = ""
- self.__Marks = 0
- self.__Topic = ""
- def setQuestion(self):
- questionText = input("Enter question text: ")
- self.__QuestionText = questionText
- answer = input("Enter the answer: ")
- self.__Answer = answer
- while True:
- marks = input("Enter the marks: ")
- try:
- marks = int(marks)
- break
- except ValueError:
- print("Not a number")
- self.__Marks = marks
- topic = input("Enter the topic: ")
- self.__Topic = topic
- def getQuestion(self):
- return self.__QuestionText
- def GetMarks(self):
- return self.__Marks
- def GetTopic(self):
- return self.__Topic
- def GetAnswer(self):
- return self.__Answer
- Tesj = Tesj("JA")
- Tesj.DesignTesj()
- Tesj.PrintTesj()
- input()
- Tesj.PrintAnswers()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement