Skip to main content

Out of curiosity a port of love letter generator in c#

This is for my Harley-Queen(still waiting): this is a cook up code to tinker around:
 
using System;
using System.Text;
 
namespace LoveLetter
{
    internal class Program
    {
  static string NextRandomWord(string[] arr, Random rand) => arr[rand.Next(0, arr.Length)];
 
        private static void Main()
        {
            var salutation1 = new string[] { "Beloved""Darling""Dear",
          "Dearest""Fanciful""Honey" };
            var salutation2 = new string[] { "Chickpea""Dear",
                      "Duck""Jewel""Love""Moppet""Sweetheart" };
            var adjs = new string[] { "affectionate""amorous""anxious",
            "avid""beautiful""breathless""burning",
            "covetous""craving""curious""eager""fervent",
             "fondest""loveable""lovesick""loving""passionate",
           "precious""seductive""sweet""sympathetic""tender",
            "unsatisfied""winning""wistful" };
            var nouns = new string[] { "adoration""affection""ambition",
          "appetite""ardour""being""burning""charm""craving",
           "desire""devotion""eagerness""enchantment""enthusiasm",
        "fancy""fellow feeling""fervour""fondness""heart""hunger",
            "infatuation""little liking""longing""love""lust",
          "passion""rapture""sympathy""thirst""wish""yearning" };
            var advs = new string[] { "affectionately""ardently""anxiously",
             "beautifully""burningly""covetously""curiously",
        "eagerly""fervently""fondly""impatiently""keenly",
            "lovingly""passionately""seductively",
       "tenderly""wistfully" };
            var verbs = new string[] { "adores""attracts""clings to",
             "holds dear""hopes for""hungers for""likes",
       "longs for""loves""lusts after""pants for""pines for",
             "sighs for""tempts""thirsts for",
         "treasures""yearns for""woos" };
 
            int LONG = 1;
            int SHORT = 2;
            int? last = null;
            var rand = new Random();
            string ll;
            string concat = "";
            var builder = new StringBuilder();
            builder.Append($"{NextRandomWord(salutation1, rand)} 
                           { NextRandomWord(salutation2, rand)} \n");
            int numberOfLines = rand.Next(57);
            for (var i = 0; i < numberOfLines; i++)
            {
                if (rand.Next(09< 5)
                {
                    //LONG
                    var optadj1 = (rand.Next(09< 5? "" : NextRandomWord(adjs, rand);
                    var noun1 = NextRandomWord(nouns, rand);
                    var optadv = (rand.Next(09< 5? "" : NextRandomWord(advs, rand);
                    var verb = NextRandomWord(verbs, rand);
                    var optadj2 = (rand.Next(09< 5? "" : NextRandomWord(adjs, rand);
                    var noun2 = NextRandomWord(nouns, rand);
                    if (last != null || last == LONG)
                    {
                        concat = ". ";
                    }
                    builder.Append($"{concat} My {optadj1} {noun1} {optadv} {verb} your 
                                     { optadj2}
                    { noun2}
                    ");
                    last = LONG;
                }
                else
                {
                    //SHORT
                    var adj = NextRandomWord(adjs, rand);
                    var noun = NextRandomWord(nouns, rand);
                    if (last == SHORT)
                    {
                        concat = ", ";
                    }
                    else if (last == LONG)
                    {
                        concat = ". You are";
                    }
                    else
                    {
                        concat = "You are ";
                    }
                    builder.Append($"{concat} my {adj} {noun}");
                    last = SHORT;
                }
            }
            ll = builder.ToString();
            var adv = NextRandomWord(advs, rand);
            ll += string.Format(".\n     Yours {0},\n     {1}.\n", adv, "Yourname");
            Console.WriteLine(ll);
            Console.ReadKey();
        }
    }
}

Comments

Popular posts from this blog

The Indian supremacy theory.

The I ndian supremacy theory : I believe We Indians are supreme above every other human races in the world cuz we are more humane, we are open to incorporate other cultures evolve & adapt to take in the goodness from others & also share what's good in ours. We are more humane & we care for our family & love them more than anything else in the world. We are superior cuz we don't separate ourselves from other people on the basis caste Creed religion nationality. We belong to a bigger United world. Working together for a common goal "betterment of life of everyone in this world & other". By referring one as an "Indian" we point to those people who, no matter where, when, how he or she born or live,  live a life of loving & caring, irrespective & above of all the caste Creed classification, working for the betterment of life & there by the Nature and the Oneness . Don't separate ourselves from other cuz, we are different

Programming challenge: escape from devil & whirlpool

  Problem : Between Devil and Deep Sea Below is the story line  A band of pirates have made loot. By their misfortune though, instant Karma is delivered. While they are travelling a treacherous route in the high and the deep seas they are also haunted by a devil, perhaps a spirit who suffered at their hands previously. The pirates now have to make tricky decisions. They run forward to save themselves from the Devil, but the deep seas force them backwards. There is a danger of falling in a whirlpool if they move forward rashly and there is a danger of being caught by the Devil if they move too much back. But move they must. First they recede backwards B meters and then advance forward F meters, in a straight line. They cover 1 meter in T units of time. This backward and forward movement is performed repeatedly by the Pirates because they have panicked. Your task is to find out if they will perish at the hands of the Devil or they will get sucked into the whirlpool of the Dee