Anonymous Anonymous - 13 days ago
142 0

No description

C#

Program.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Lektion3Ovning
{
    class Program
    {
        static void Main(string[] args)
        {
            List<int> numberList = new List<int>() { 1, 2, 3, 4, 5 };
            List<string> nameList = new List<string>() { "David", "Pelle", "Linus" };
            foreach (int number in numberList)
            {
                Console.WriteLine(number);
            }

            foreach (string name in nameList)
            {
                Console.WriteLine(name);
            }
            Car volvo = new Car(); 
            volvo.Make = "Volvo";
            Console.WriteLine(value: $"Märke: {volvo.Make} ");
            volvo.Gas();
            volvo.Gas();
            Console.WriteLine("--------------");
            Car saab = new Car();
            saab.Make = "Saab";
            Console.WriteLine($"Märke: {saab.Make} ");
            saab.Gas();
            saab.Gas();

        }
    }
}
C#

Car.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Lektion3Ovning
{
    class Car
    {
        public int Speed { get; set; }
        public string Make { get; set; }



        public int Gas()
        {
            Speed += 10;
            Console.WriteLine($"Speed: {Speed}km/h");
            return Speed;
        }
    }
}
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download