Пример #1
0
        public void DeletTAssignment(DataClasses1DataContext db, ASSIGNMENT assignment)
        {
            int assignment_id = GetAssignmentIDToInteger();

            assignment = db.ASSIGNMENTs.Single(i => i.ASSIGNMENT_ID == assignment_id);
            db.ASSIGNMENTs.DeleteOnSubmit(assignment);
            db.SubmitChanges();
            Console.WriteLine("\n\tDeleted Succesfull!!!");
        }
Пример #2
0
        public void UpdateAssignmentPerCourses(ASSIGNMENT_PER_COURSE assignmentPerCourse, DataClasses1DataContext db)
        {
            Assignment assignment = new Assignment();
            ASSIGNMENT aSSignment = new ASSIGNMENT();
            Course     course     = new Course();

            Console.WriteLine("\n\n\t" + "UPATE ASSIGNMENTS PER COURSES" +
                              "\n\t-----------------------------");

            aSSignment = assignment.UpdateAssignment(db, aSSignment);
            int courseID = GetCourseIdFromAssignmentID(db, aSSignment.ASSIGNMENT_ID);

            assignmentPerCourse.ASSIGNMENT_ID = aSSignment.ASSIGNMENT_ID;
            assignmentPerCourse.COURSE_ID     = courseID;
            db.SubmitChanges();

            Console.WriteLine("\n\tAssignments Per Courses was successfully enrolled!!!");
        }
Пример #3
0
        public void CreateTrainerPerCourses(ASSIGNMENT_PER_COURSE assignmentPerCourse, DataClasses1DataContext db)
        {
            Course     course     = new Course();
            Assignment assignment = new Assignment();
            ASSIGNMENT aSSignmnet = new ASSIGNMENT();

            Console.WriteLine("\n\n\t" + "CREATE ASSIGNMENTS PER COURSES" +
                              "\n\t------------------------------");

            aSSignmnet = assignment.CreateAssignment(aSSignmnet, db);
            int courseID = course.GetCourseIDForCreate();

            assignmentPerCourse.ASSIGNMENT_ID = aSSignmnet.ASSIGNMENT_ID;
            assignmentPerCourse.COURSE_ID     = courseID;
            db.ASSIGNMENT_PER_COURSEs.InsertOnSubmit(assignmentPerCourse);
            db.SubmitChanges();

            Console.WriteLine("\n\tΤhe student was successfully enrolled!!!");
        }
Пример #4
0
        public void MenuAssignment(DataClasses1DataContext db)
        {
            ASSIGNMENT assignment = new ASSIGNMENT();
            string     stringChoice;

            Console.WriteLine("\n\tASSIGNMENT MENU\n\t" + "---------------");
            Console.WriteLine("\tCreate Assignment press   --->  {1}");
            Console.WriteLine("\tRead Assignment press     --->  {2}");
            Console.WriteLine("\tUpdate Assignment press   --->  {3}");
            Console.WriteLine("\tDelete Assignment press   --->  {4}");
            Console.Write("\tEnter a choice between ---> {1 - 4}: ");
            stringChoice = Console.ReadLine();
            int outChoice;

            while (!int.TryParse(stringChoice, out outChoice) || outChoice < 1 || outChoice > 4)
            {
                Console.WriteLine("\n\tThe choice should be Only integer between {1- 4}!!!");
                Console.Write("\tEnter a new choice: ");
                stringChoice = Console.ReadLine();
            }
            int choice = outChoice;

            switch (choice)
            {
            case (int)SelectionAssignment.create:
                CreateAssignment(assignment, db);
                break;

            case (int)SelectionAssignment.read:
                ReadAssignment(db);
                break;

            case (int)SelectionAssignment.update:
                UpdateAssignment(db, assignment);
                break;

            case (int)SelectionAssignment.delete:
                DeletTAssignment(db, assignment);
                break;
            }
        }
Пример #5
0
        public void DeletAssignmentsPerCourses(ASSIGNMENT_PER_COURSE assignmentPerCourse, DataClasses1DataContext db)
        {
            Course     course     = new Course();
            ASSIGNMENT aSSignment = new ASSIGNMENT();
            Assignment assignment = new Assignment();

            Console.WriteLine("\n\n\t" + "DELETE ASSIGNMENTS PER COURSES" +
                              "\n\t------------------------------");

            int assignmentID = assignment.GetAssignmentIdFOfCreate();
            int courseID     = GetCourseIdFromAssignmentID(db, aSSignment.ASSIGNMENT_ID);

            assignmentPerCourse = db.ASSIGNMENT_PER_COURSEs.Single(i => i.ASSIGNMENT_ID == assignmentID);

            assignmentPerCourse.ASSIGNMENT_ID = assignmentID;
            assignmentPerCourse.COURSE_ID     = courseID;
            db.ASSIGNMENT_PER_COURSEs.DeleteOnSubmit(assignmentPerCourse);
            db.SubmitChanges();

            Console.WriteLine("\n\tDeleted Succesfully!!!");
        }
Пример #6
0
 protected override void Visit_ASSIGNMENT(ASSIGNMENT node)
 {
     /* MOVE CODE HERE */
 }
Пример #7
0
 protected override void Visit_ASSIGNMENT(ASSIGNMENT node)
 {
     last = new GNode(node, last, this);
 }
Пример #8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="scfg"></param>
        /// <param name="aprot">If called for an agent activity - implemented protocol, otherwise null</param>
        /// <returns></returns>
        public bool Validate(SourceContext defaultContext)
        {
            HashSet <int> exclude = new HashSet <int>();

            foreach (GNode g in scfg.allNodes)
            {
                g.visited = false;
            }

            if (aprot != null && !aprot.ErrorReported)
            {
                aprot.syntax.validate(); aprot.syntax.convert();
                if (aprot.syntax.table != null)
                {
                    ptotable[0] = new Rules(aprot.syntax.table.GetServerEBNF(), aprot.syntax.testFunction.tests, "(" + aprot.Name + ") anonymous client");
                    scfg.entry.AddStateFor(ptotable[0].id, 0); //Entry point
                }
            }
            Queue <GNode> visitNext = new Queue <GNode>();

            visitNext.Enqueue(scfg.entry);
            GNode node = scfg.entry;

            while (visitNext.Count > 0)
            {
                node         = visitNext.Dequeue();
                node.visited = true;
                foreach (GNode next in node.successors)
                {
                    bool needtocopy = true;
                    if (next.astNode is ASSIGNMENT)
                    { // Interested in p := new A;
                        ASSIGNMENT nnode = next.astNode as ASSIGNMENT;
                        if (nnode.right_part is NEW && nnode.right_part.type is ACTIVITY_TYPE)
                        {
                            if (nnode.receiver is INSTANCE)
                            {
                                int id = ((INSTANCE)nnode.receiver).entity.unique;

                                ACTIVITY_TYPE acttype = nnode.right_part.type as ACTIVITY_TYPE;
                                if (((ACTIVITY_DECL)(acttype.activity)).prototype is PROTOCOL_DECL)
                                {
                                    if (!((ACTIVITY_DECL)(acttype.activity)).prototype.ErrorReported)
                                    {
                                        PROTOCOL_DECL eprot = ((ACTIVITY_DECL)(acttype.activity)).prototype as PROTOCOL_DECL;
                                        eprot.syntax.validate(); eprot.syntax.convert();
                                        if (eprot.syntax.table != null)
                                        {
                                            ptotable[id] = new Rules(eprot.syntax.table.GetClientEBNF(), eprot.syntax.testFunction.tests, "(" + eprot.name + ")" + ((INSTANCE)nnode.receiver).Name);
                                            next.AddStateFor(ptotable[id].id, 0);
                                            node.ForwardAllStatesExceptOneTo(next, ptotable[id].id);
                                            needtocopy = false;
                                        }
                                    }
                                }
                                else
                                { // Else it's ok. Do not trace this variable
                                    // Add to exclude set. All other cases will be treated with error: Not initialized dialog
                                    exclude.Add(id);
                                }
                            }
                            else
                            {
                                if (!nnode.ErrorReported)
                                {
                                    ERROR.ActivityVariableMustBeLocal(nnode.sourceContext);
                                }
                                nnode.ErrorReported = true;
                            }
                        }
                        else if ((nnode.right_part is CALL) &&
                                 (((CALL)nnode.right_part).callee is INSTANCE && (((CALL)nnode.right_part).type is ABSTRACT_ACTIVITY_TYPE || ((CALL)nnode.right_part).type is ACTIVITY_TYPE))
                                 )
                        {
                            int id = ((INSTANCE)((CALL)nnode.right_part).callee).entity.unique;
                            if (!exclude.Contains(id))
                            {
                                if (ptotable.ContainsKey(id))
                                {
                                    Rules rules = ptotable[id];
                                    foreach (int protocolState in node.GetStatesFor(rules.id))
                                    {
                                        int nextstate = protocolState;
                                        for (int i = 0; i < ((CALL)nnode.right_part).arguments.Length; i++)
                                        {
                                            EXPRESSION des       = ((CALL)nnode.right_part).arguments[i];
                                            int        savestate = nextstate;
                                            if ((nextstate = ValidateDataTransfer(rules, nextstate, false, des, true)) < 0)
                                            {
                                                if (!next.astNode.ErrorReported && !rules.errorReported)
                                                {
                                                    ERROR.ProtocolViolation(next.astNode.sourceContext, rules.ExpectedAtState(savestate, true));
                                                    next.astNode.ErrorReported = true;
                                                    rules.errorReported        = true;
                                                }
                                            }
                                            else if (nextstate == 0) // This was the last send/receive
                                            {
                                                nextstate = -1;
                                            }
                                        }
                                        { /* Process the receive */
                                            EXPRESSION des       = nnode.receiver;
                                            int        savestate = nextstate;
                                            if ((nextstate = ValidateDataTransfer(rules, nextstate, true, des, false)) < 0)
                                            {
                                                if (!next.astNode.ErrorReported && !rules.errorReported)
                                                {
                                                    ERROR.ProtocolViolation(next.astNode.sourceContext, rules.ExpectedAtState(savestate, true));
                                                    next.astNode.ErrorReported = true;
                                                    rules.errorReported        = true;
                                                }
                                            }
                                            else if (nextstate == 0) // This was the last send/receive
                                            {
                                                nextstate = -1;
                                            }
                                        }

                                        next.AddStateFor(rules.id, nextstate);
                                        node.ForwardAllStatesExceptOneTo(next, rules.id);
                                        needtocopy = false;
                                    }
                                }
                                else
                                {
                                    ERROR.AcceptCalledForInvalidDialog(nnode.sourceContext);
                                }
                            }
                        }
                    }
                    else if (next.astNode is ACCEPT)
                    {
                        ACCEPT anode = next.astNode as ACCEPT;
                        if (ptotable.ContainsKey(0))
                        {
                            Rules rules = ptotable[0];
                            foreach (int protocolState in node.GetStatesFor(rules.id))
                            {
                                int nextstate = protocolState;
                                for (int i = 0; i < anode.designators.Length; i++)
                                {
                                    EXPRESSION des       = anode.designators[i];
                                    int        savestate = nextstate;
                                    if ((nextstate = ValidateDataTransfer(rules, nextstate, false, des, false)) < 0)
                                    {
                                        if (!next.astNode.ErrorReported && !rules.errorReported)
                                        {
                                            ERROR.ProtocolViolation(next.astNode.sourceContext, rules.ExpectedAtState(savestate, false));
                                            next.astNode.ErrorReported = true;
                                            rules.errorReported        = true;
                                        }
                                    }
                                    else if (nextstate == 0) // This was the last send/receive
                                    {
                                        nextstate = -1;
                                    }
                                }
                                next.AddStateFor(rules.id, nextstate);
                                node.ForwardAllStatesExceptOneTo(next, rules.id);
                                needtocopy = false;
                            }
                        }
                    }
                    else if (next.astNode is REPLY)
                    {
                        REPLY rnode = next.astNode as REPLY;
                        if (ptotable.ContainsKey(0))
                        {
                            Rules rules = ptotable[0];
                            foreach (int protocolState in node.GetStatesFor(rules.id))
                            {
                                int nextstate = protocolState;
                                for (int i = 0; i < rnode.values_to_reply.Length; i++)
                                {
                                    EXPRESSION des       = rnode.values_to_reply[i];
                                    int        savestate = nextstate;
                                    if ((nextstate = ValidateDataTransfer(rules, nextstate, true, des, true)) < 0)
                                    {
                                        if (!next.astNode.ErrorReported && !rules.errorReported)
                                        {
                                            ERROR.ProtocolViolation(next.astNode.sourceContext, rules.ExpectedAtState(savestate, false));
                                            next.astNode.ErrorReported = true;
                                            rules.errorReported        = true;
                                        }
                                    }
                                    else if (nextstate == 0) // This was the last send/receive
                                    {
                                        nextstate = -1;
                                    }
                                }
                                next.AddStateFor(rules.id, nextstate);
                                node.ForwardAllStatesExceptOneTo(next, rules.id);
                                needtocopy = false;
                            }
                        }
                    }
                    else if (next.astNode is SEND_RECEIVE)
                    {
                        SEND_RECEIVE snode = next.astNode as SEND_RECEIVE;
                        if (snode.call.call.callee is INSTANCE)
                        {
                            int id = ((INSTANCE)snode.call.call.callee).entity.unique;
                            if (!exclude.Contains(id))
                            {
                                if (ptotable.ContainsKey(id))
                                {
                                    Rules rules = ptotable[id];
                                    foreach (int protocolState in node.GetStatesFor(rules.id))
                                    {
                                        int nextstate = protocolState;
                                        if (snode.call.call != null)
                                        {
                                            for (int i = 0; i < snode.call.call.arguments.Length; i++)
                                            {
                                                EXPRESSION des       = snode.call.call.arguments[i];
                                                int        savestate = nextstate;
                                                if ((nextstate = ValidateDataTransfer(rules, nextstate, false, des, true)) < 0)
                                                {
                                                    if (!next.astNode.ErrorReported && !rules.errorReported)
                                                    {
                                                        ERROR.ProtocolViolation(next.astNode.sourceContext, rules.ExpectedAtState(savestate, true));
                                                        next.astNode.ErrorReported = true;
                                                        rules.errorReported        = true;
                                                    }
                                                }
                                                else if (nextstate == 0) // This was the last send/receive
                                                {
                                                    nextstate = -1;
                                                }
                                            }
                                        }
                                        if (snode.leftParts != null)
                                        {
                                            for (int i = 0; i < snode.leftParts.Length; i++)
                                            {
                                                EXPRESSION des       = snode.leftParts[i];
                                                int        savestate = nextstate;
                                                if ((nextstate = ValidateDataTransfer(rules, nextstate, true, des, false)) < 0)
                                                {
                                                    if (!next.astNode.ErrorReported && !rules.errorReported)
                                                    {
                                                        ERROR.ProtocolViolation(next.astNode.sourceContext, rules.ExpectedAtState(savestate, true));
                                                        next.astNode.ErrorReported = true;
                                                        rules.errorReported        = true;
                                                    }
                                                }
                                                else if (nextstate == 0) // This was the last send/receive
                                                {
                                                    nextstate = -1;
                                                }
                                            }
                                        }
                                        next.AddStateFor(rules.id, nextstate);
                                        node.ForwardAllStatesExceptOneTo(next, rules.id);
                                        needtocopy = false;
                                    }
                                }
                                else
                                {
                                    ERROR.AcceptCalledForInvalidDialog(snode.sourceContext);
                                }
                            }
                        }
                        else
                        {
                            if (!snode.ErrorReported)
                            {
                                ERROR.ActivityVariableMustBeLocal(snode.sourceContext);
                            }
                            snode.ErrorReported = true;
                        }
                    }
                    else if (next.astNode is CALL_STMT)
                    {
                        CALL_STMT cnode = next.astNode as CALL_STMT;
                        if (cnode.call.callee is INSTANCE && (cnode.call.type is ABSTRACT_ACTIVITY_TYPE || cnode.call.type is ACTIVITY_TYPE))
                        {
                            int id = ((INSTANCE)cnode.call.callee).entity.unique;
                            if (!exclude.Contains(id))
                            {
                                if (ptotable.ContainsKey(id))
                                {
                                    Rules rules = ptotable[id];
                                    foreach (int protocolState in node.GetStatesFor(rules.id))
                                    {
                                        int nextstate = protocolState;
                                        if (cnode.call != null)
                                        {
                                            for (int i = 0; i < cnode.call.arguments.Length; i++)
                                            {
                                                EXPRESSION des       = cnode.call.arguments[i];
                                                int        savestate = nextstate;
                                                if ((nextstate = ValidateDataTransfer(rules, nextstate, false, des, true)) < 0)
                                                {
                                                    if (!next.astNode.ErrorReported && !rules.errorReported)
                                                    {
                                                        ERROR.ProtocolViolation(next.astNode.sourceContext, rules.ExpectedAtState(savestate, true));
                                                        next.astNode.ErrorReported = true;
                                                        rules.errorReported        = true;
                                                    }
                                                }
                                                else if (nextstate == 0) // This was the last send/receive
                                                {
                                                    nextstate = -1;
                                                }
                                            }
                                        }

                                        next.AddStateFor(rules.id, nextstate);
                                        node.ForwardAllStatesExceptOneTo(next, rules.id);
                                        needtocopy = false;
                                    }
                                }
                            }
                            else
                            {
                                ERROR.AcceptCalledForInvalidDialog(cnode.sourceContext);
                            }
                        }
                    }

                    if (needtocopy)
                    {
                        node.ForwardAllStatesTo(next);
                    }

                    if (!next.visited)
                    {
                        visitNext.Enqueue(next);
                    }
                }
            }
            // We leave the graph. All protocols in the last node must be in -1 state

            foreach (Rules rule in ptotable.Values)
            {
                foreach (int protocolState in node.GetStatesFor(rule.id))
                {
                    if (!ValidateEnd(rule, protocolState) && !rule.errorReported)
                    {
                        ERROR.ProtocolNotCompleted(new SourceContext(defaultContext.Document, defaultContext.EndPos - 3, defaultContext.EndPos), rule.name, rule.ExpectedAtState(protocolState, true));
                    }
                }
            }
            return(true);
        }
Пример #9
0
        public ASSIGNMENT CreateAssignment(ASSIGNMENT assignment, DataClasses1DataContext db)
        {
            Check_ID check_ID = new Check_ID();
            DateTime date     = new DateTime();

            Console.WriteLine("\n\n\t" + "CREATE ASSIGNMENT" + "\n\t-----------------");
            assignment = new ASSIGNMENT();

            Console.Write("\t" + "Assignment ID (Only Integer!): ");
            string assignmentId = Console.ReadLine();
            int    assignmentIdOut;

            while (!int.TryParse(assignmentId, out assignmentIdOut) || assignmentIdOut <= 0)
            {
                Console.WriteLine("\n\t" + "Assignment ID should be Only Integer and not Zero!!!");
                Console.Write("\t" + "Give a new Assignment ID: ");
                assignmentId = Console.ReadLine();
            }
            int assignmnetIDAfterCheck = check_ID.positiveIntegerForAssignmnetID(assignmentIdOut);

            assignment.ASSIGNMENT_ID = check_ID.UniqueAssignmentID(assignmnetIDAfterCheck, db);

            Console.Write("\t" + "Title (Only Letter!): ");
            assignment.TITLE = Console.ReadLine();

            while (!assignment.TITLE.All(char.IsLetter) || string.IsNullOrEmpty(assignment.TITLE))
            {
                Console.Write("\n\t" + "Assignment Title should be Only Letter!!!");
                Console.Write("\n\t" + "Give a new Assignment Title: ");
                assignment.TITLE = Console.ReadLine();
            }
            assignment.TITLE.ToUpper();

            Console.Write("\t" + "Description (Only Letter!): ");
            assignment.DESCRIPTIONN = Console.ReadLine();

            while (!assignment.DESCRIPTIONN.All(char.IsLetter) || string.IsNullOrEmpty(assignment.DESCRIPTIONN))
            {
                Console.Write("\n\t" + "Assignment Description should be Only Letter!!!");
                Console.Write("\n\t" + "Give a new Assignment Description: ");
                assignment.DESCRIPTIONN = Console.ReadLine();
            }
            assignment.DESCRIPTIONN.ToUpper();

            Console.Write("\t" + "Subbmision date and time (Example: {" + $"{DateTime.Now.ToShortDateString()}" + "}): ");
            string subbmisionDateAndTime = Console.ReadLine();

            while (!DateTime.TryParse(subbmisionDateAndTime, out date))
            {
                Console.Write("\n\tInvalid Date Type!!!\n\tExample {" + $"{DateTime.Now.ToShortDateString()}" + "}: ");
                subbmisionDateAndTime = Console.ReadLine();
            }
            DateTime dateTime = date;

            assignment.SUBMISSION_DATE_AND_TIME = dateTime;

            Console.Write("\t" + "Assignment Oral Mark (Only Decimal!): ");
            string  assignmentOralMark = Console.ReadLine();
            decimal assignmentOralMarkOut;

            while (!decimal.TryParse(assignmentOralMark, out assignmentOralMarkOut))
            {
                Console.WriteLine("\n\t" + "Assignment Oral Mark should be Only Decimal!!!");
                Console.Write("\t" + "Give a new Assignment Oral Mark: ");
                assignmentOralMark = Console.ReadLine();
            }
            decimal assignmentORalMark = assignmentOralMarkOut;

            assignment.ORAL_MARK = assignmentORalMark;

            Console.Write("\t" + "Assignment Total Mark (Only Decimal!): ");
            string  assignmentTotalMark = Console.ReadLine();
            decimal assignmentTotalMarkOut;

            while (!decimal.TryParse(assignmentTotalMark, out assignmentTotalMarkOut))
            {
                Console.WriteLine("\n\t" + "Assignment Total Mark should be Only Decimal!!!");
                Console.Write("\t" + "Give a new Assignment Total Mark: ");
                assignmentTotalMark = Console.ReadLine();
            }
            decimal assignmenTOtalMark = assignmentTotalMarkOut;

            assignment.TOTAL_MARK = assignmenTOtalMark;

            InsertAssignment(assignment, db);
            Console.WriteLine("\n\tCreate Assignment Cuccessfully!!!");

            return(assignment);
        }
Пример #10
0
        public ASSIGNMENT UpdateAssignment(DataClasses1DataContext db, ASSIGNMENT assignment)
        {
            Console.WriteLine("\n\tEnter Assignment ID you want to change: ");
            string stringChoice;

            Console.WriteLine("\n\tUPDATE Assignment\n\t" + "-----------------");
            Console.WriteLine("\tFor title press                     --> {1}");
            Console.WriteLine("\tFor description press               --> {2}");
            Console.WriteLine("\tFor Subbmision date and time press  --> {3}");
            Console.WriteLine("\tFor Oral Mark press                 --> {4}");
            Console.WriteLine("\tFor Total Mark press                --> {5}");
            Console.Write("\tEnter a choice: ");
            stringChoice = Console.ReadLine();

            int outChoice;

            while (!int.TryParse(stringChoice, out outChoice) || string.IsNullOrEmpty(stringChoice) || outChoice < 1 || outChoice > 5)
            {
                Console.WriteLine("\n\tThe choice should be Only integer between {1- 5}!!!");
                Console.Write("\tEnter a new choice: ");
                stringChoice = Console.ReadLine();
            }
            int choice = outChoice;

            switch (choice)
            {
            case (int)SelectionUpDateForAssignment.title:
                int assignmentID = GetAssignmentIDToInteger();
                assignment = db.ASSIGNMENTs.Single(i => i.ASSIGNMENT_ID == assignmentID);
                Console.Write("\tEnter new Firstname: ");
                assignment.TITLE = Console.ReadLine();

                while (!assignment.TITLE.All(char.IsLetter) || string.IsNullOrEmpty(assignment.TITLE))
                {
                    Console.Write("\n\t" + "Assignment Title should be Only Letter!!!");
                    Console.Write("\n\t" + "Give a new Assignment Title: ");
                    assignment.TITLE = Console.ReadLine();
                }
                assignment.TITLE.ToUpper();
                db.SubmitChanges();
                Console.WriteLine("\n\tChange Title Cuccessfully!!!");
                break;

            case (int)SelectionUpDateForAssignment.description:
                int assignment_Id = GetAssignmentIDToInteger();
                assignment = db.ASSIGNMENTs.Single(i => i.ASSIGNMENT_ID == assignment_Id);
                Console.Write("\tEnter new Description: ");
                assignment.DESCRIPTIONN = Console.ReadLine();

                while (!assignment.DESCRIPTIONN.All(char.IsLetter) || string.IsNullOrEmpty(assignment.DESCRIPTIONN))
                {
                    Console.Write("\n\t" + "Assignment Description should be Only Letter!!!");
                    Console.Write("\n\t" + "Give a new Assignment Description: ");
                    assignment.DESCRIPTIONN = Console.ReadLine();
                }
                assignment.DESCRIPTIONN.ToUpper();
                db.SubmitChanges();
                Console.WriteLine("\n\tChange Description Cuccessfully!!!");
                break;

            case (int)SelectionUpDateForAssignment.subbmision_Date_And_Time:
                DateTime date          = new DateTime();
                int      assignment_iD = GetAssignmentIDToInteger();
                assignment = db.ASSIGNMENTs.Single(i => i.ASSIGNMENT_ID == assignment_iD);
                Console.Write("\t" + "Enter new Subbmision Date And Time (Example: {" + $"{DateTime.Now.ToShortDateString()}" + "}): ");
                string subbmisionDateAndTime = Console.ReadLine();

                while (!DateTime.TryParse(subbmisionDateAndTime, out date))
                {
                    Console.Write("\n\tInvalid Date Type!!!\n\tExample {" + $"{DateTime.Now.ToShortDateString()}" + "}: ");
                    subbmisionDateAndTime = Console.ReadLine();
                }
                DateTime dateTime = date;
                assignment.SUBMISSION_DATE_AND_TIME = dateTime;
                db.SubmitChanges();
                break;

            case (int)SelectionUpDateForAssignment.oral_Mark:
                int assignMent_id = GetAssignmentIDToInteger();
                assignment = db.ASSIGNMENTs.Single(i => i.ASSIGNMENT_ID == assignMent_id);
                Console.Write("\tEnter new Oral Mark ID: ");
                string  newAssignmentID = Console.ReadLine();
                decimal newassignmentOut;

                while (!decimal.TryParse(newAssignmentID, out newassignmentOut))
                {
                    Console.WriteLine("\n\t" + "Trainer ID should be Only Integer!!!");
                    Console.Write("\t" + "Give a new Trainer ID: ");
                    newAssignmentID = Console.ReadLine();
                }
                decimal newAssIgnmentID = newassignmentOut;
                assignment.ORAL_MARK = newAssIgnmentID;
                db.SubmitChanges();
                Console.WriteLine("\n\tChange Oral Mark Cuccessfully!!!");
                break;

            case (int)SelectionUpDateForAssignment.total_Mark:
                int asSignMeNt_id = GetAssignmentIDToInteger();
                assignment = db.ASSIGNMENTs.Single(i => i.ASSIGNMENT_ID == asSignMeNt_id);
                Console.Write("\tEnter new Total Mark: ");
                string  newAssIgNmeNtID = Console.ReadLine();
                decimal newAsSignmEntOut;

                while (!decimal.TryParse(newAssIgNmeNtID, out newAsSignmEntOut))
                {
                    Console.WriteLine("\n\t" + "Total Mark should be Only Integer!!!");
                    Console.Write("\t" + "Give a new Total Mark: ");
                    newAssIgNmeNtID = Console.ReadLine();
                }
                decimal newAsSigNmENtID = newAsSignmEntOut;
                assignment.TOTAL_MARK = newAsSigNmENtID;
                db.SubmitChanges();
                Console.WriteLine("\n\tChange Total Mark Cuccessfully!!!");
                break;
            }
            return(assignment);
        }
Пример #11
0
 public void InsertAssignment(ASSIGNMENT assignment, DataClasses1DataContext db)
 {
     db.ASSIGNMENTs.InsertOnSubmit(assignment);
     db.SubmitChanges();
 }
Пример #12
0
 protected virtual void Visit_ASSIGNMENT(ASSIGNMENT node)
 {
 }
Пример #13
0
 ExpressionConverter(ASSIGNMENT assignment)
 {
     _generatedClass = new Class();
     _arguments      = new Dictionary <String, Int32>();
 }
Пример #14
0
        static Class Convert(ASSIGNMENT assignment)
        {
            ExpressionConverter converter = new ExpressionConverter(assignment);

            return(converter._generatedClass);
        }
Пример #15
0
        /// <summary>
        /// The function processes all kinds of statements including
        /// assignments, calls, and variable/constant declarations.
        /// </summary>
        /// <param name="context"></param>
        /// <returns>true, if any construct (a statement, or a simple declaration)
        /// was processed, and false otherwise.</returns>
        public static bool parse(iSCOPE context, TokenCode stop1, TokenCode stop2, TokenCode stop3)
        {
            Debug.Indent();
            Debug.WriteLine("Entering STATEMENT.parse");

            bool result = true;

            Token token = get();
            Token begin = token;

            if (token.code == stop1 && stop1 != TokenCode.ERROR)
            {
                goto Finish;
            }
            if (token.code == stop2 && stop2 != TokenCode.ERROR)
            {
                goto Finish;
            }
            if (token.code == stop3 && stop3 != TokenCode.ERROR)
            {
                goto Finish;
            }

            switch (token.code)
            {
            // case TokenCode.Pure: -- doesn't make any sense
            case TokenCode.Safe:
            case TokenCode.Routine:
                ROUTINE.parse(token, false, false, false, 0, context);
                break;

            case TokenCode.If:
                IF.parse(context);
                break;

            case TokenCode.While:
            case TokenCode.Loop:
                LOOP.parse(null, context);
                break;

            // Break
            //     : break [ Label ]
            //
            // Label
            //     : Identifier
            case TokenCode.Break:
                BREAK.parse(context);
                break;

            // Statement
            //     : ...
            //     | raise [ Expression ]
            case TokenCode.Raise:
                forget();
                RAISE.parse(token.span, context);
                break;

            // Statement
            //     : ...
            //     | check PredicatesList end
            //     | ...
            case TokenCode.Check:
                CHECK.parse(context);
                break;

            // Statement
            //     : ...
            //     | return [ Expression ]
            //     | ...
            case TokenCode.Return:
                forget();
                EXPRESSION expr = EXPRESSION.parse(null, context);    // can be null
                RETURN     ret  = new RETURN(expr);
                if (expr != null)
                {
                    expr.parent = ret;
                    ret.setSpan(begin.span, expr.span);
                }
                else
                {
                    ret.setSpan(begin);
                }

                context.add(ret);
                break;

            // Statement
            //     : ...
            //     | Try
            //     | ...
            //
            // Try
            //     : try { Statement } Catches [ Else ] end
            //
            // Catches
            //     : catch [ "(" [ Identifier ":" ] Type ")" ] { Statement }
            //
            // Else
            //     : else { Statement }
            case TokenCode.Try:
                TRY.parse(context);
                break;

            // Statement
            //     : ...
            //     | ? Identifier
            //     | ...
            //
            case TokenCode.Question:

                break;

            case TokenCode.Init:
                // Initializer call
                forget();
                Token start = token;

                DECLARATION init = Context.find(INITIALIZER.initName);
                EXPRESSION  initRef;
                if (init != null)
                {
                    initRef = new REFERENCE(init);
                }
                else
                {
                    initRef = new UNRESOLVED(context, new IDENTIFIER(INITIALIZER.initName));
                }

                CALL call = new CALL(initRef);
                token = expect(TokenCode.LParen);
                while (true)
                {
                    EXPRESSION argument = EXPRESSION.parse(null, context);
                    call.add(argument);
                    argument.parent = call;

                    token = get();
                    if (token.code == TokenCode.Comma)
                    {
                        forget(); continue;
                    }
                    break;
                }
                token = expect(TokenCode.RParen);
                call.setSpan(start.span, token.span);
                context.add(call);
                break;

            case TokenCode.Identifier:
            {
                // Several different cases:
                //   - a label in front of while/loop
                //   - a declaration
                //   - a statement

                forget();
                Token next = get();
                if (next.code == TokenCode.LParen)
                {
                    forget();
                    TokenCode codeAfter = saveTokensUntilRightParenth(next);
                    switch (codeAfter)
                    {
                    case TokenCode.Colon:
                    case TokenCode.Is:
                    // case TokenCode.Do:
                    case TokenCode.Arrow:
                        //This as a routine declaration!!
                        ROUTINE.parse(token, false, false, false, 0, context);
                        goto Weiter;
                    }
                }
                EXPRESSION attempt = EXPRESSION.parse(token, context);
                if (attempt is UNRESOLVED)
                {
                    // Might be a label or a declaration...
                    Token idd = new Token(attempt.span, TokenCode.Identifier,
                                          (attempt as UNRESOLVED).name.identifier,
                                          new Category(CategoryCode.identifier));
                    token = get();
                    switch (token.code)
                    {
                    case TokenCode.Is:
                    case TokenCode.Comma:
                        // This is definitely a declaration
                        forget();
                        VARIABLE.parse(false, false, false, false, idd, token, context);
                        goto Weiter;

                    case TokenCode.Colon:
                        forget();
                        Token token2 = get();
                        if (token2.code == TokenCode.While || token2.code == TokenCode.Loop)
                        {
                            // This is a real label! Don't 'forget()'.
                            LOOP.parse(idd, context);
                        }
                        else
                        {
                            // This is definitely a variable declaration.
                            // Don't forget()
                            VARIABLE.parse(false, false, false, false, idd, token, context);
                        }
                        goto Weiter;

                    default:
                        // Nothing to do; just going further
                        break;
                    }
                }
                // 'attempt' is something else: a call or the left part of an assignment
                token = get();
                if (token.code == TokenCode.Assign)
                {
                    forget();
                    EXPRESSION right = EXPRESSION.parse(null, context);
                    ASSIGNMENT res   = new ASSIGNMENT(attempt, right);
                    res.setSpan(attempt.span, right.span);
                    context.add(res);
                }
                else
                {
                    if (!(attempt is CALL))       // something's wrong
                    {
                        result = false;
                    }
                    context.add(attempt);
                }
Weiter:
                break;
            }

            case TokenCode.Const:
                // Something like
                //     const a is 5...
                // OR
                //     const is a, b, ... end
                forget(); token = get();
                if (token.code == TokenCode.Is)
                {
                    forget();
                    CONSTANT.parse(context);
                }
                else
                {
                    VARIABLE.parse(false, false, true, false, null, null, context);
                }
                break;

            default:
                // Something else, e.g., (a... or this...
                // Either a function call or an assignment.
                //
                //     this := ...
                //     (if cond then a else b).f ...
                //     ^

                EXPRESSION e = EXPRESSION.parse(null, context);
                if (e == null)
                {
                    // Either an error or just the end of statement sequence
                    result = false;
                    break;
                }
                token = get();
                if (token.code == TokenCode.Assign)
                {
                    forget();
                    EXPRESSION right      = EXPRESSION.parse(null, context);
                    ASSIGNMENT assignment = new ASSIGNMENT(e, right);
                    assignment.setSpan(e.span, right.span);
                    context.add(assignment);
                }
                else
                {
                    context.add(e);
                }
                break;
            }
Finish:
            Debug.WriteLine("Exiting STATEMENT.parse");
            Debug.Unindent();

            return(result);
        }