예제 #1
0
        public IHttpActionResult Putchoice(int id, choice choice)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != choice.sn)
            {
                return(BadRequest());
            }

            db.Entry(choice).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!choiceExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
 private choice Edit(choice c)
 {
     c.modiDate        = DateTime.Now;
     db.Entry(c).State = EntityState.Modified;
     db.SaveChanges();
     return(c);
 }
        private void button1_Click(object sender, EventArgs e)
        {
            if (numItems.Value == 0)
            {
                MessageBox.Show("No. of items needed is currently 0, please input the quantity of items you need");
            }
            else
            {
                string  pickeditem    = cmbItem.Text;
                string  pickeditemprc = lblItemPrice.Text;
                decimal PickedPrice   = Convert.ToDecimal(pickeditemprc);
                decimal pickeditemqty = numItems.Value;
                decimal totalprice    = PickedPrice * pickeditemqty; //multiply the item price and the number bought by the customer

                choice x = new choice
                {
                    ChosenItem  = pickeditem,
                    ChosenPick  = pickeditemqty,
                    ChosenTotal = totalprice
                };
                Choices.Add(x);                                                        //adds them to the list to be moved to form2

                decimal leftstock = decimal.Parse(lblitemsLeft.Text) - numItems.Value; //reduces the value of stock whenever something is added to cart
                lblitemsLeft.Text = leftstock.ToString();                              //due to not being a requirement, this part just works aesthetically
                numItems.Maximum  = leftstock;                                         //whenever the item is re selected it resets the stock amount
            }
        }
예제 #4
0
        public static choice getAIinput()
        {
            Random random   = new Random(DateTime.Now.Millisecond);
            choice AIchoice = (choice)random.Next(1, 4);

            return(AIchoice);
        }
        private void cmdClearAnswer_Click(object sender, EventArgs e)
        {
            ClearInputBoxes();
            cmdClearAnswer.Visible = false;

            QuestionAnsweredEventArgs qe = new QuestionAnsweredEventArgs();

            qe.Choice = _choice;

            if (QuestionCleared != null)
            {
                QuestionCleared(this, qe);
            }

            try
            {
                _choice.Delete();
                _choice = null;
            }
            catch (Exception err)
            {
                LoggingHelper.Log("Error deleting choice in CallQuestionAnswerDisplay.ClearAnswer", LogSeverity.Error, err, false);
                MessageBox.Show(this, "An error occurred erasing your choice. Please report the following error to a system administrator:\n\n" +
                                err.Message, "Error removing choice");
            }
        }
    // update variables with player's choice (rock, paper, scissors, nuke, antinuke)
    void ChoiceListen()
    {
        // player one controls

        if (Input.GetKey(controls.P1Confirm))
        {
            confirmedP1 = true;
            // display on UI that p1 confimred
            p1ConfirmedGUI.SetText("Ready");
        }
        else if (Input.GetKey(controls.P1Rock))
        {
            p1Choice = choice.ROCK;
        }
        else if (Input.GetKey(controls.P1Paper))
        {
            p1Choice = choice.PAPER;
        }
        else if (Input.GetKey(controls.P1Scissors))
        {
            p1Choice = choice.SCISSORS;
        }
        else if (Input.GetKey(controls.P1Nuke))
        {
            p1Choice = choice.NUKE;
        }
        else if (Input.GetKey(controls.P1AntiNuke))
        {
            p1Choice = choice.ANTINUKE;
        }

        //player two controls

        if (Input.GetKey(controls.P2Confirm))
        {
            confirmedP2 = true;
            p2ConfirmedGUI.SetText("Ready");
            // display on UI that p2 is confirmed
        }
        else if (Input.GetKey(controls.P2Rock))
        {
            p2Choice = choice.ROCK;
        }
        else if (Input.GetKey(controls.P2Paper))
        {
            p2Choice = choice.PAPER;
        }
        else if (Input.GetKey(controls.P2Scissors))
        {
            p2Choice = choice.SCISSORS;
        }
        else if (Input.GetKey(controls.P2Nuke))
        {
            p2Choice = choice.NUKE;
        }
        else if (Input.GetKey(controls.P2AntiNuke))
        {
            p2Choice = choice.ANTINUKE;
        }
    }
예제 #7
0
        private static bool processMenu(choice option)
        {
            switch (option)
            {
            case choice.Add:
                addingCode();
                break;

            case choice.Delete:
                deletingCode();
                break;

            case choice.Update:
                updatingCode();
                break;

            case choice.Find:
                findingCode();
                break;

            default:
                return(false);
            }
            return(true);
        }
예제 #8
0
파일: Tester.cs 프로젝트: AliHosny/weet-it
 public static void test(String inputPath, String outputPath, choice myChoise)
 {
     openExcel(inputPath, outputPath);
     getURIs(myChoise);
     getURIsfromExcel();
     comparePredicates();
     avgTimeNResults();
 }
예제 #9
0
 public Form1()
 {
     InitializeComponent();
     dist_args = new string[5] { "Feet", "Miles", "Kilometers", "Meters", "Yards" };
     speed_args = new string[2] { "Miles/Hr", "Km/Hr" };
     time_args = new string[4] { "Minutes", "Seconds", "Hours", "Days" };
     typeChoice = choice.None;
     amount = 0;
 }
예제 #10
0
        public void winner_msg_7()
        {
            choice user     = choice.paper;
            choice ai       = choice.Scissors;
            string expected = "Scissors cuts paper.soScissors wins.";
            string actual   = Program.getwinningmessage(user, ai);

            Assert.AreEqual(expected, actual);
        }
예제 #11
0
        public void winner_msg_6()
        {
            choice user     = choice.Scissors;
            choice ai       = choice.Scissors;
            string expected = "same choice.what a coincidence.";
            string actual   = Program.getwinningmessage(user, ai);

            Assert.AreEqual(expected, actual);
        }
예제 #12
0
        public void winner_msg_4()
        {
            choice user     = choice.Rock;
            choice ai       = choice.Scissors;
            string expected = "Rock breaks Scissors.so Rock wins.";
            string actual   = Program.getwinningmessage(user, ai);

            Assert.AreEqual(expected, actual);
        }
예제 #13
0
        public void winner_msg_3()
        {
            choice user     = choice.paper;
            choice ai       = choice.Rock;
            string expected = "paper covers Rock.so paper wins.";
            string actual   = Program.getwinningmessage(user, ai);

            Assert.AreEqual(expected, actual);
        }
예제 #14
0
        public void get_winner_9()
        {
            choice       a        = choice.Scissors;
            choice       b        = choice.Scissors;
            winningstate actual   = Program.getwinner(a, b);
            winningstate expected = winningstate.draw;

            Assert.AreEqual(expected, actual);
        }
예제 #15
0
        public void get_winner_7()
        {
            choice       a        = choice.paper;
            choice       b        = choice.Rock;
            winningstate actual   = Program.getwinner(a, b);
            winningstate expected = winningstate.userwins;

            Assert.AreEqual(expected, actual);
        }
 public CallQuestionAnswerDisplay(question q, choice c, call ca)
 {
     InitializeComponent();
     _question               = q;
     _choice                 = c;
     _currentCall            = ca;
     lblDataDescription.Text = q.text;
     SetQuestion();
 }
예제 #17
0
        static void Main(string[] args)
        {
            bool   processing = true;
            string menu       = getMenu();

            do
            {
                choice option = (choice)Helper.GetNumber(menu);
                processing = processMenu(option);
            } while (processing);
        }
예제 #18
0
        public IHttpActionResult Getchoice(int id)
        {
            choice choice = db.choices.Find(id);

            if (choice == null)
            {
                return(NotFound());
            }

            return(Ok(choice));
        }
예제 #19
0
 static void Main(string[] args)
 {
     #region game workflow
     //single round match
     //Console.WriteLine("******************welcome to AI powered rps game*****");
     //choice userchoice=getuserinput("enter your choice(1.rock,2.paper,3.scissor):");
     //choice AIchoice=getAIinput();
     //displaychoices(userchoice,AIchoice);
     //winningstate currentwinner=getwinner
     //multiple rounds-5;
     int AIwincount   = 0;
     int userwincount = 0;
     int drawcount    = 0;
     for (int i = 0; i < 5; i++)
     {
         if (userwincount >= 3 || AIwincount >= 3)
         {
             printwinner(AIwincount, userwincount, drawcount);
             break;
         }
         Console.Clear();
         Console.ForegroundColor = ConsoleColor.Blue;
         Console.WriteLine("*******welcome AI************");
         Console.WriteLine();
         Console.ForegroundColor = ConsoleColor.Yellow;
         Console.WriteLine("*******this is round:" + (i + 1) + "************");
         Console.WriteLine("******current standing in game**********");
         Console.WriteLine();
         Console.ForegroundColor = ConsoleColor.Green;
         Console.WriteLine("user win count:" + userwincount + "AI win count:" + AIwincount + "draw count:" + drawcount);
         Console.WriteLine();
         Console.WriteLine();
         Console.ForegroundColor = mycolor;
         choice userchoice = getuserinput("enter rps");
         choice AIchoice   = getAIinput();
         displaychoices(userchoice, AIchoice);
         winningstate currentwinner = getwinner(userchoice, AIchoice);
         if (currentwinner == winningstate.AIwins)
         {
             AIwincount++;
         }
         else if (currentwinner == winningstate.userwins)
         {
             userwincount++;
         }
         else if (currentwinner == winningstate.draw)
         {
             drawcount++;
         }
         string winningmessage = getwinningmessage(userchoice, AIchoice);
         displayresult(currentwinner, winningmessage);
     }
     printwinner(AIwincount, userwincount, drawcount);
 }
 public choice setData(choice c)
 {
     if (c.sn == 0)
     {
         return(AddNew(c));
     }
     else
     {
         return(Edit(c));
     }
 }
        private choice GetNewCallChoice()
        {
            choice newChoice = new choice();

            newChoice.created_at     = DateTime.Now;
            newChoice.operatordata   = ActiveUser.UserObject.username;
            newChoice.LinkedCall     = _currentCall;
            newChoice.LinkedQuestion = Question;


            return(newChoice);
        }
예제 #22
0
        public IHttpActionResult Postchoice(choice choice)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.choices.Add(choice);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = choice.sn }, choice));
        }
예제 #23
0
    // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
    override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        if (!WorkDone)
        {
            randomDirection  = Random.insideUnitSphere * walkRadius;
            randomDirection += go.transform.position;
            NavMeshHit hit;
            NavMesh.SamplePosition(randomDirection, out hit, walkRadius, 1);
            finalPosition = hit.position;
            go.GetComponent <NavMeshAgent>().destination = finalPosition;

            //Debug.Log("start " + go.transform.position);
            //Debug.Log("end " + finalPosition);

            //GameObject.FindGameObjectWithTag("Respawn").transform.position = finalPosition;

            var conta = (finalPosition - go.transform.position).normalized;
            //Debug.Log("X: " + conta.x + " - Z: " + conta.z);
            sr.flipX = (conta.x > 0 || conta.z <= 0) || (conta.z < 0 || conta.x >= 0);

            escolha = new WeightedRandom(new List <choice> {
                new choice {
                    nome = "IDLE", probabilidade = 60
                }
            }).Escolhe();

            WorkDone = true;
            oldpos   = Vector3.zero;
            return;
        }

        if (oldpos == Vector3.zero)
        {
            oldpos = go.transform.position;
            return;
        }

        if (go.transform.position == oldpos)
        {
            WorkDone = false;

            if (escolha != null)
            {
                animator.SetTrigger(escolha.nome);
            }
        }
        else
        {
            oldpos = go.transform.position;
        }

        return;
    }
예제 #24
0
 // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
 override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     go       = GameObject.FindGameObjectWithTag("Player");
     sr       = GameObject.FindGameObjectWithTag("playersprite").GetComponent <SpriteRenderer>();
     sr.flipX = false;
     //timeUntilDecision = Random.Range(1f, 3f) * 60;
     WorkDone      = false;
     escolha       = null;
     finalPosition = Vector3.zero;
     oldpos        = Vector3.zero;
     walkRadius    = 2;
 }
    void InitRockPaperScissorsNuke()
    {
        p1Choice = choice.NONE;
        p2Choice = choice.NONE;

        // init the graphics
        p1ChoiceGUI.enabled = false;
        p2ChoiceGUI.enabled = false;
        p1Score.SetText(GameState.Instance.ScorePlayer1.ToString() + " POINTS");
        p2Score.SetText(GameState.Instance.ScorePlayer2.ToString() + " POINTS");

        state = RPSNGameState.ANIMATIONS_WAIT;
    }
예제 #26
0
    choice getCurrChoice(choice[] choices)
    {
        choice ret = new choice();

        for (int i = 0; i < choices.Length; i++)
        {
            if (choices [i].value)
            {
                ret = choices [i];
            }
        }
        return(ret);
    }
예제 #27
0
        public IHttpActionResult Deletechoice(int id)
        {
            choice choice = db.choices.Find(id);

            if (choice == null)
            {
                return(NotFound());
            }

            db.choices.Remove(choice);
            db.SaveChanges();

            return(Ok(choice));
        }
        private void UpdateAnswer(string answer)
        {
            string answerText = answer;

            if (Choice != null)
            {
                if (Choice.LinkedCall.ReadOnly)
                {
                    return; // Cancel edit (this is a past call)
                }
            }
            else
            {
                _choice = GetNewCallChoice();
            }

            if (Question.type == question.QuestionTypes.YesNo)
            {
                if (answer == true.ToString())
                {
                    answerText = "Yes";
                    Text       = Question.text + ": Yes";
                }
                else if (answer == false.ToString())
                {
                    answerText = "No";
                    Text       = Question.text + ": No";
                }
            }
            else
            {
                Text = Question.text + ": " + Choice.answer;
            }
            _choice.answer = answerText;
            QuestionAnsweredEventArgs ea = new QuestionAnsweredEventArgs();

            ea.Choice = _choice;

            if (QuestionAnswered != null)
            {
                QuestionAnswered(this, ea);
            }


            Choice.Save();
            // currentChoiceIsDirty = true;

            cmdClearAnswer.Visible = true;
        }
예제 #29
0
        public IHttpActionResult NabobbetsCreate(List <betDto> betlist)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var count    = 0;
            var eqchoice = 0;

            foreach (var bet in betlist)
            {
                user  u  = db.users.Where(p => p.userID == bet.userId && p.comSn == bet.comSn).FirstOrDefault();
                game  g  = db.games.Where(x => x.sn == bet.gameSn).FirstOrDefault();
                topic tc = db.topics.Where(x => x.gameSn == bet.gameSn).FirstOrDefault();

                if (u == null)
                {
                    return(BadRequest("UserID不存在"));
                }
                bet.userSn = u.sn;
                bet.valid  = 1;
                Mapper.Initialize(cfg => {
                    cfg.CreateMap <betDto, bet>();
                });
                bet b = Mapper.Map <bet>(bet);

                choice cho = db.choices.Where(p => p.sn == b.choiceSn).FirstOrDefault();
                b.Odds    = cho.Odds;
                b.topicSn = cho.topicSn;

                db.bets.Add(b);
                db.SaveChanges();
                //只有新模式才會新增
                if (count == 0)
                {
                    eqchoice = b.sn;
                }
                b.equalchoice     = eqchoice;
                db.Entry(b).State = EntityState.Modified;

                db.SaveChanges();
                count++;
            }



            return(Ok(betlist));
        }
예제 #30
0
        /// <summary>
        /// Constructor
        /// </summary>
        public MainForm()
        {
            this.genericAttributes      = new String[0];
            this.genericGeneralSkills   = new Dictionary <String, String>();
            this.genericWrestlingSkills = new Dictionary <String, Wrestler.modifier>();
            this.genericBodyParts       = new String[0];
            this.formchoice             = choice.attribute;
            this.attWindow  = new Attributes(this);
            this.bdptWindow = new BodyParts(this);
            this.gnskWindow = new GeneralSkills(this);
            this.wrskWindow = new WrestlingSkills(this);

            InitializeComponent();

            this.attributes_Click(new object(), new EventArgs());
        }
예제 #31
0
        public void addQuestions(string path)
        {
            string          line      = "";
            List <question> questions = new List <question>();


            using (StreamReader sr = new StreamReader(path))
            {
                question q            = new question();
                choice   c            = new choice();
                answer   a            = new answer();
                int      numOfChoices = 0;

                course crs = (from C in BaseInfo.rtc.courses
                              where C.course_name == comboBox1.Text
                              select C).ToList <course>()[0];
                q.course_id = crs.id;
                while (!sr.EndOfStream)
                {
                    q.id            = BaseInfo.rtc.questions.Count() + 1;
                    q.question_desc = sr.ReadLine();
                    numOfChoices    = Convert.ToInt32(sr.ReadLine());
                    for (int i = 0; i < numOfChoices; i++)
                    {
                        c.choice_desc = sr.ReadLine();
                        c.question_id = q.id;
                        q.choices.Add(c);

                        c = new choice();
                    }
                    a.question_id = q.id;
                    a.answer_desc = sr.ReadLine();

                    q.answers.Add(a);

                    questions.Add(q);

                    a = new answer();


                    q = new question();
                }
                BaseInfo.rtc.questions.AddRange(questions);
                BaseInfo.rtc.SaveChanges();
            }
            MessageBox.Show(line);
        }
예제 #32
0
        /// <summary>
        /// Displays all the attributes in the side menu, after clearing out
        /// the items
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void attributes_Click(object sender, EventArgs e)
        {
            this.listthings.Items.Clear();
            if (genericAttributes.Length != 0)
            {
                foreach (String att in genericAttributes)
                {
                    this.listthings.Items.Add(att);
                }
            }

            this.formchoice = choice.attribute;

            this.attributesButton.FlatStyle = FlatStyle.Flat;
            this.bpartsButton.FlatStyle     = FlatStyle.Standard;
            this.gskillsButton.FlatStyle    = FlatStyle.Standard;
            this.wskillsButton.FlatStyle    = FlatStyle.Standard;
        }
예제 #33
0
        private void dataSelection_SelectedValueChanged(object sender, EventArgs e)
        {
            from.Items.Clear();
            from.Text = "";
            to.Items.Clear();
            to.Text = "";
            Amt.Enabled = false;
            if (dataSelection.Text == "Distance")
            {
                foreach (string str in dist_args)
                {
                    from.Items.Add(str);
                    to.Items.Add(str);
                }
                typeChoice = choice.Distance;

            }
            else if (dataSelection.Text == "Speed")
            {
                foreach (string str in speed_args)
                {
                    from.Items.Add(str);
                    to.Items.Add(str);
                }
                typeChoice = choice.Speed;
            }

            else if (dataSelection.Text == "Time")
            {
                foreach (string str in time_args)
                {
                    from.Items.Add(str);
                    to.Items.Add(str);
                }
                typeChoice = choice.Time;
            }
            from.Enabled = true;
            to.Enabled = true;
        }
예제 #34
0
파일: Tester.cs 프로젝트: AliHosny/weet-it
 private static void getURIs(choice myChoice)
 {
     for (int iLimit = 5; iLimit <= 50; iLimit += 5)
     for (int iTopN = 1; (iTopN <= 25 && iTopN < iLimit); iTopN += 3)
     {
         myworksheet2.Cells[1][position] = iLimit;
         myworksheet2.Cells[2][position] = iTopN;
         position++;
         List<double> tTime = new List<double>();
         List<List<String>> concludedURI = new List<List<String>>();
         for (int i = 2; i <= range1.Rows.Count; i++)
             {
                 Microsoft.Office.Interop.Excel.Range myrange = myworksheet1.get_Range("A" + i.ToString(), System.Reflection.Missing.Value);
                 String s = myrange.Text;
                 DateTime start = DateTime.Now;
                 if (myChoice == choice.Predicate)
                     predicates = mylexicon.getPredicates(s, iTopN, iLimit);
                 else
                     literals = mylexicon.getLiterals(s, iTopN, iLimit);
                 DateTime end = DateTime.Now;
                 tTime.Add((end - start).TotalMilliseconds);
                 List<String> URIsForOneItem = new List<String>();
                 if (myChoice == choice.Predicate)
                     foreach (LexiconPredicate predicate in predicates)
                     {
                         URIsForOneItem.Add(predicate.URI);
                         util.log(predicate.ToSimpleString());
                     }
                 else
                     foreach (LexiconLiteral literal in literals)
                     {
                         URIsForOneItem.Add(literal.URI);
                         util.log(literal.ToSimpleString());
                     }
                 concludedURI.Add(URIsForOneItem);
             }
             time.Add(tTime);
             allConcludedURIs.Add(concludedURI);
     }
 }