コード例 #1
0
        public static void Main()
        {
            int day_of_competition = 1;

            Console.WriteLine("Welcome to the Travis County Fishing Competition! You have 31 days to catch a \n" +
                              "150 lbs Carp.");
            Console.ReadLine();
            Console.WriteLine("Upgrading your rod will allow you to hold on to bigger catches, while upgrading your bait will " +
                              "allow you to catch bigger and better fish.");
            Console.ReadLine();
            Console.WriteLine("At the end of each day, you can sell your catches to earn more money. \n" +
                              "To begin press Enter");
            Console.ReadLine();


            bool loop = true;

            while (loop == true)
            {
                //Opening text each turn
                Console.WriteLine("\n\n\n\n\nWelcome to day {0} of the Travis County Fishing Competition!\n",
                                  day_of_competition);

                //Choose a Rod
                current_rod = inv.DisplayRods();

                //Choose a Bait
                current_bait = inv.DisplayBait();

                //Begin the day's fishing and return the day's catches
                inv.catch_of_the_day = pond.Cast(current_rod, current_bait);

                //Display the day's catches and sell them
                inv.sell_fish();

                Console.WriteLine("\nPress Enter to continue...");
                Console.ReadLine();

                //Check for win
                if (inv.goal_reached == true)
                {
                    Console.WriteLine("You win! You caught a 150 lbs carp in " + day_of_competition + " days!" +
                                      "\n\nPlease press Enter to exit");
                    Console.ReadLine();
                    break;
                }

                //Ending Sequence
                if (day_of_competition >= 31)
                {
                    Console.WriteLine("Sometimes the fish just aren't biting...Maybe next month!\n\nPlease press Enter to exit");
                    Console.ReadLine();
                    loop = false;
                }
                else
                {
                    day_of_competition++;
                }
            }
        }
コード例 #2
0
        public FishingRod DisplayRods()
        {
            bool loop = true;

            while (loop == true)
            {
                byte counter = 1;
                Console.WriteLine("   " + "Rod" + "\t\t\t" + " Cost" + "\t" + "     Max Poundage\n");
                foreach (FishingRod rod in rods)
                {
                    StringBuilder amount_of_space = new StringBuilder(" ");
                    amount_of_space.Length = (20 - rod.name.Length) + 4;
                    string printout = counter + " " + rod.name + amount_of_space + "$" + rod.cost + "\t\t";
                    if (rod.name == "Heavy Graphite")
                    {
                        printout += "NO MAX";
                    }
                    else
                    {
                        printout += rod.max_poundage + " lbs";
                    }

                    Console.WriteLine(printout);
                    counter++;
                }
                Console.WriteLine("\n" + "Choose a Rod: " + "\t\t\t     Wallet: $" + Math.Round(wallet, 2));

                string   rodchoice       = Console.ReadLine();
                string[] possiblechoices = { "1", "2", "3", "4", "5" };


                foreach (string choice in possiblechoices)
                {
                    if (rodchoice == choice)
                    {
                        Byte bytechoice = Convert.ToByte(choice);
                        foreach (FishingRod rod in rods)
                        {
                            rod.current = false;
                        }

                        FishingRod chosenrod = rods[bytechoice - 1];
                        if (chosenrod.cost <= wallet)
                        {
                            chosenrod.current = true;
                            wallet           -= chosenrod.cost;
                            chosenrod.cost    = 0;
                            return(chosenrod);     //Return the chosen rod
                        }
                    }
                }
            }

            return(rods[0]);
        }
コード例 #3
0
        //Determines what the player catches based on what the current rod and bait is this round
        public List <Fish> Cast(FishingRod current_rod, Bait current_bait)
        {
            caughtfish.Clear();
            string caught = "";
            double weight = 0;

            for (byte i = 1; i <= 20; i++)
            {
                int randomcatch = RandomInt.Next(1, 20 + 1);        //Check if player catches a fish at all
                if (randomcatch + current_bait.catch_chance_increase >= 20)
                {
                    int whichfish = RandomInt.Next(current_bait.min_roll, current_bait.max_roll + 1);  //Determines the kind of fish caught
                    foreach (Fish fish in pondfish)
                    {
                        if (whichfish >= fish.min_catch_roll)
                        {
                            if (whichfish <= fish.max_catch_roll)
                            {
                                Fish landedfish = new Fish(fish.name, fish.min_catch_roll,
                                                           fish.max_catch_roll, fish.min_weight,
                                                           fish.max_weight, fish.price_per_pound);
                                landedfish.weight = landedfish.min_weight + RandomDouble.NextDouble() *
                                                    (landedfish.max_weight - landedfish.min_weight);
                                if (landedfish.weight >= current_rod.max_poundage)
                                {
                                    caught = "Your rod is too small, the line broke!";
                                    weight = 0;
                                }
                                else
                                {
                                    caughtfish.Add(landedfish);
                                    caught = landedfish.name;
                                    weight = landedfish.weight;
                                }
                            }
                        }
                    }
                }
                else
                {
                    caught = "No Bite";
                    weight = 0;
                }

                string printout = ("Chance " + i + "..." + caught);
                Thread.Sleep(120);
                if (weight != 0)
                {
                    printout += (", " + Math.Round(weight, 2) + " lbs");
                }
                Console.WriteLine(printout);
            }
            return(caughtfish);
        }
コード例 #4
0
        //Determines what the player catches based on what the current rod and bait is this round
        public List<Fish> Cast(FishingRod current_rod, Bait current_bait)
        {
            caughtfish.Clear();
            string caught = "";
            double weight = 0;
            for (byte i = 1; i <= 20; i++)
            {
                int randomcatch = RandomInt.Next(1, 20 + 1);        //Check if player catches a fish at all
                if (randomcatch + current_bait.catch_chance_increase >= 20)
                {
                    int whichfish = RandomInt.Next(current_bait.min_roll, current_bait.max_roll + 1);  //Determines the kind of fish caught
                    foreach (Fish fish in pondfish)
                    {
                        if (whichfish >= fish.min_catch_roll)
                        {
                            if (whichfish <= fish.max_catch_roll)
                            {
                                Fish landedfish = new Fish(fish.name, fish.min_catch_roll,
                                                           fish.max_catch_roll, fish.min_weight,
                                                           fish.max_weight, fish.price_per_pound);
                                landedfish.weight = landedfish.min_weight + RandomDouble.NextDouble() *
                                                   (landedfish.max_weight - landedfish.min_weight);
                                if (landedfish.weight >= current_rod.max_poundage)
                                {
                                    caught = "Your rod is too small, the line broke!";
                                    weight = 0;
                                }
                                else
                                {
                                    caughtfish.Add(landedfish);
                                    caught = landedfish.name;
                                    weight = landedfish.weight;
                                }
                            }
                        }
                    }

                }
                else
                {
                    caught = "No Bite";
                    weight = 0;

                }

                string printout = ("Chance " + i + "..." + caught);
                Thread.Sleep(120);
                if (weight != 0)
                    printout += (", " + Math.Round(weight, 2) + " lbs");
                Console.WriteLine(printout);

            }
            return caughtfish;
        }
コード例 #5
0
        public static void Main()
        {
            int day_of_competition = 1;

            Console.WriteLine("Welcome to the Travis County Fishing Competition! You have 31 days to catch a \n" +
                              "150 lbs Carp.");
            Console.ReadLine();
            Console.WriteLine("Upgrading your rod will allow you to hold on to bigger catches, while upgrading your bait will " +
                              "allow you to catch bigger and better fish.");
            Console.ReadLine();
            Console.WriteLine("At the end of each day, you can sell your catches to earn more money. \n" +
                              "To begin press Enter");
            Console.ReadLine();

            bool loop = true;
            while (loop == true)
            {
                //Opening text each turn
                Console.WriteLine("\n\n\n\n\nWelcome to day {0} of the Travis County Fishing Competition!\n",
                                    day_of_competition);

                //Choose a Rod
                current_rod = inv.DisplayRods();

                //Choose a Bait
                current_bait = inv.DisplayBait();

                //Begin the day's fishing and return the day's catches
                inv.catch_of_the_day = pond.Cast(current_rod, current_bait);

                //Display the day's catches and sell them
                inv.sell_fish();

                Console.WriteLine("\nPress Enter to continue...");
                Console.ReadLine();

                //Check for win
                if (inv.goal_reached == true)
                {
                    Console.WriteLine("You win! You caught a 150 lbs carp in " + day_of_competition + " days!" +
                                      "\n\nPlease press Enter to exit");
                    Console.ReadLine();
                    break;
                }

                //Ending Sequence
                if (day_of_competition >= 31)
                {
                    Console.WriteLine("Sometimes the fish just aren't biting...Maybe next month!\n\nPlease press Enter to exit");
                    Console.ReadLine();
                    loop = false;
                }
                else
                    day_of_competition ++;
            }
        }