コード例 #1
0
 //these two functions, Use() and Use(ref object target), fully implement the IUseableItem interface
 public void Use()
 {
     TextFormatter.PrintLinePositive("You see your own scrawled, messy handwriting.");
     TextFormatter.PrintLineWarning("4/1/20");
     //just FYI this is the intro sequence and I just added it as a reminder as to what the player is doing and who the player is supposed to be :)
     TextFormatter.PrintLineWarning("To anyone who finds this book: I am a scientist here in this world. It is a blessing and a curse. One day, as I was sitting at my desk, quarantined in my lab, I noticed a face mask blow by in the wind. I reminisced to the old days before Big 'Rona ruled the world and everyone suffered her oppression. Back when I could high-five my friends, and have a meeting without worrying about wifi. Suddenly, in that moment, I realized that it was my destiny to defeat Big ‘Rona. I saw that a long journey to defeat Big ‘Rona and her minions lay ahead, and I understood the dangers I would be facing. I made sure to fully prepare myself with masks, toilet paper, and Purell. Tubs of purell. I wrote this as my final note to my love if anything ever happened to me. Bertha, my love, my pet cow, my life, I hope I will be able to see you again. Wish me luck! <3");
 }
コード例 #2
0
        /// <summary>
        /// TODO: VM Hard Achievement
        /// Convert a String like "400g 34c" into a Money object.
        /// You should be able to Enter large numbers, but not negative numbers.
        /// (after all, these properties are "unsigned integers")
        ///
        /// So, "2841924c" is a valid string
        /// but, "-24p" is not.
        ///
        /// "10p 249g 24s 842c" is valid but not in simplest terms, so it is
        /// up to you how you will handle the difference.
        ///
        /// </summary>
        /// <param name="displayString"></param>
        public Money(string displayString)
        {
            if (!displayString.Contains('-'))
            {
                //we split the string entered as a parameter into multiple parts (if any)
                //these splitparts then are added to create an array
                string[] moneyParts = displayString.Split(' ');

                //then we run a loop that goes through each part
                //each time we loop, we check whether the monetary amount in in units of c, s, g, or p
                //player will recieve separate warnings for having mixed units (ex: 25 cg), having no units (ex: 25), or negative money amounts (ex: -25c)
                for (int i = 0; i == moneyParts.Length - 1; i++)
                {
                    if (moneyParts[i].Contains('c'))
                    {
                        moneyParts[i] = moneyParts[i].Remove('c');
                        if (!moneyParts[i].Contains('s') && !moneyParts[i].Contains('g') && !moneyParts[i].Contains('p'))
                        {
                            Copper = Convert.ToUInt16(moneyParts[i], 16);
                        }
                        else
                        {
                            TextFormatter.PrintLineWarning("Hmm...mixed units of money...? Only one unit per number please.");
                        }
                    }
                    else if (moneyParts[i].Contains('s'))
                    {
                        moneyParts[i] = moneyParts[i].Remove('s');
                        if (!moneyParts[i].Contains('c') && !moneyParts[i].Contains('g') && !moneyParts[i].Contains('p'))
                        {
                            Silver = Convert.ToUInt16(moneyParts[i], 16);
                        }
                        else
                        {
                            TextFormatter.PrintLineWarning("Hmm...mixed units of money...? Only one unit per number please.");
                        }
                    }
                    else if (moneyParts[i].Contains('g'))
                    {
                        moneyParts[i] = moneyParts[i].Remove('g');
                        if (!moneyParts[i].Contains('c') && !moneyParts[i].Contains('s') && !moneyParts[i].Contains('p'))
                        {
                            Gold = Convert.ToUInt16(moneyParts[i], 16);
                        }
                        else
                        {
                            TextFormatter.PrintLineWarning("Hmm...mixed units of money...? Only one unit per number please.");
                        }
                    }
                    else if (moneyParts[i].Contains('p'))
                    {
                        moneyParts[i] = moneyParts[i].Remove('p');
                        if (!moneyParts[i].Contains('c') && !moneyParts[i].Contains('s') && !moneyParts[i].Contains('g'))
                        {
                            Platinum = Convert.ToUInt16(moneyParts[i], 16);
                        }
                        else
                        {
                            TextFormatter.PrintLineWarning("Hmm...mixed units of money...? Only one unit per number please.");
                        }
                    }
                    else
                    {
                        TextFormatter.PrintLineWarning("Remember to add monetary units at the end of your money amounts (ex: Make sure to write 5p and not just 5).");
                    }
                }
            }
            else
            {
                TextFormatter.PrintLineWarning("Negative money is bad! Don't even think about typing negative signs!!!");
            }
        }