+1 (315) 557-6473 

C# Program to Implement Get Info Function Assignment Solution.


Instructions

Objective
Write a C# assignment program to implement a 'get info' function in C#. This program should focus on creating a function that retrieves information and demonstrates your understanding of C# programming concepts.

Requirements and Specifications

program to implement get info function in C sharp

Screenshots

program to implement get info function in C sharp 1

Source Code

PROGRAM

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

namespace AshmeeApp

{

    class Program

    {

        static void Main(string[] args)

        {

            // Ask user for budget

            int budget = 0;

            Console.Write("Please enter your budget: $");

            budget = Convert.ToInt32(Console.ReadLine());

            // Create Retailer object

            Retailer retailer = new Retailer();

            TV tv = retailer.replenishTV(budget);

            if(tv != null) // the tv object returned by Retailer is not null

            {

                // Display TV info

                Console.WriteLine("With a budget of $" + budget + " you can acquire the following TV:");

                Console.WriteLine(tv.getInfo());

            }

            // Execute a Console.Read so console is not closed until user presses a key

            Console.Read();

        }

    }

}

RETAILER

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

namespace AshmeeApp

{

    class Retailer

    {

        public TV replenishTV(int budget)

        {

            TV tvObject = null;

            if (budget >= 200)

                tvObject = new TV();

            if (budget >= 250)

                tvObject = new Vizio_TV();

            if (budget >= 280)

                tvObject = new Sony_TV();

            if (budget >= 300)

                tvObject = new Smart_TV();

            if (budget >= 350)

                tvObject = new Vizio_Smart_TV();

            if (budget >= 380)

                tvObject = new Sony_Smart_TV();

            if (budget >= 400)

                tvObject = new UltraHD_TV();

            if (budget >= 450)

                tvObject = new Vizio_UltraHD_TV();

            if (budget >= 480)

                tvObject = new Sony_UltraHD_TV();

            return tvObject;

        }

    }

}