Skip to content

I want to try uploading some of my amatuer work here as I get through C# ๐Ÿ˜’๐Ÿ˜’

Notifications You must be signed in to change notification settings

salehjoseph/mycsharpjjourney24

Repository files navigation

Welcome to my C# Learning Repository! This repository contains various projects, exercises, and code snippets that I am working on as I learn C# programming.

Table of Contents

  • Exercise (Complete a challenge activity using conditional operators)
  • Exercise (Fizzbuzz Challenge)

Introduction

I am an aspiring developer learning C# to enhance my programming skills. This repository serves as a place to document my journey and showcase the projects and exercises I complete along the way. Feedback and contributions are welcome!

Projects

-Contoso Pets Application Click Here The Contoso Pets Application is an application that's used to find homes for stray or abandoned pets

Exercises

Code Snippets ๐Ÿš€

string permission = "Admin|Manager";
int level = 60;
//permision.Contains('Admin');
 if (level > 55)
        {
            Console.WriteLine("Welcome, Super Admin user.");
        }
        else if (level <= 55 && level >= 20)
        {
            Console.WriteLine("Welcome, Admin user.");
        }
        else if (level < 20)
        {
            Console.WriteLine("You do not have sufficient privileges.");
        }

        // Check permissions if level is less than 55
        if (!permission.Contains("Admin") && !permission.Contains("Manager"))
        {
            Console.WriteLine("You do not have sufficient privileges.");
        }
        //Sample code for the Contoso Pets App 
        switch (i)
    {
        case 0:
            animalSpecies = "dog";
            animalID = "d1";
            animalAge = "2";
            animalPhysicalDescription =
                "medium sized cream colored female golden retriever weighing about 65 pounds. housebroken.";
            animalPersonalityDescription =
                "loves to have her belly rubbed and likes to chase her tail. gives lots of kisses.";
            animalNickname = "lola";
            break;

        case 1:
            animalSpecies = "dog";
            animalID = "d2";
            animalAge = "9";
            animalPhysicalDescription =
                "large reddish-brown male golden retriever weighing about 85 pounds. housebroken.";
            animalPersonalityDescription =
                "loves to have his ears rubbed when he greets you at the door, or at any time! loves to lean-in and give doggy hugs.";
            animalNickname = "loki";
            break;

        case 2:
            animalSpecies = "cat";
            animalID = "c3";
            animalAge = "1";
            animalPhysicalDescription =
                "small white female weighing about 8 pounds. litter box trained.";
            animalPersonalityDescription = "friendly";
            animalNickname = "Puss";
            break;

        case 3:
            animalSpecies = "cat";
            animalID = "c4";
            animalAge = "?";
            animalPhysicalDescription = "";
            animalPersonalityDescription = "";
            animalNickname = "";
            break;

        default:
            animalSpecies = "";
            animalID = "";
            animalAge = "";
            animalPhysicalDescription = "";
            animalPersonalityDescription = "";
            animalNickname = "";
            break;
    }

    ourAnimals[i, 0] = "ID #: " + animalID;
    ourAnimals[i, 1] = "Species: " + animalSpecies;
    ourAnimals[i, 2] = "Age: " + animalAge;
    ourAnimals[i, 3] = "Nickname: " + animalNickname;
    ourAnimals[i, 4] = "Physical description: " + animalPhysicalDescription;
    ourAnimals[i, 5] = "Personality: " + animalPersonalityDescription;
}

do
{
    // display the top-level menu options

    Console.Clear();

    Console.WriteLine("Welcome to the Contoso PetFriends app. Your main menu options are:");
    Console.WriteLine(" 1. List all of our current pet information");
    Console.WriteLine(" 2. Add a new animal friend to the ourAnimals array");
    Console.WriteLine(" 3. Ensure animal ages and physical descriptions are complete");
    Console.WriteLine(" 4. Ensure animal nicknames and personality descriptions are complete");
    Console.WriteLine(" 5. Edit an animalโ€™s age");
    Console.WriteLine(" 6. Edit an animalโ€™s personality description");
    Console.WriteLine(" 7. Display all cats with a specified characteristic");
    Console.WriteLine(" 8. Display all dogs with a specified characteristic");
    Console.WriteLine();
    Console.WriteLine("Enter your selection number (or type Exit to exit the program)");

    readResult = Console.ReadLine();
    if (readResult != null)
    {
        menuSelection = readResult.ToLower();
    }

    // Console.WriteLine($"You selected menu option {menuSelection}.");
    // Console.WriteLine("Press the Enter key to continue");

    // // pause code execution
    // readResult = Console.ReadLine();
    switch (menuSelection)
    {
        case "1":
            // List all of our current pet information
            for (int i = 0; i < maxPets; i++)
            {
                if (ourAnimals[i, 0] != "ID #: ")
                {
                    Console.WriteLine();
                    for (int j = 0; j < 6; j++)
                    {
                        Console.WriteLine(ourAnimals[i, j]);
                    }
                }
            }
            Console.WriteLine("\n\rPress the Enter key to continue");
            readResult = Console.ReadLine();

            break;

        case "2":
            // List all of our current pet information
            string anotherPet = "y";
            int petCount = 0;

            for (int i = 0; i < maxPets; i++)
            {
                if (ourAnimals[i, 0] != "ID #: ")
                {
                    petCount += 1;
                }
            }

            if (petCount < maxPets)
            {
                Console.WriteLine(
                    $"We currently have {petCount} pets that need homes. We can manage {(maxPets - petCount)} more."
                );
            }

About

I want to try uploading some of my amatuer work here as I get through C# ๐Ÿ˜’๐Ÿ˜’

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages