Advertisement
callumbinner22

Vehicle Class

Apr 24th, 2017
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.54 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace OBJECTORIENTATEDCODE
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             Vehicle mini = new Vehicle()
  14.             {
  15.                 type = "car",
  16.                 numwheels = 4,
  17.                 topspeed = 90.00,
  18.                 cost = 11000.00
  19.  
  20.             };
  21.             Vehicle eddiestobart = new Vehicle()
  22.             {
  23.                 type = "lorry",
  24.                 numwheels = 16,
  25.                 topspeed = 60.00,
  26.                 cost = 111000.00
  27.  
  28.             };
  29.             mini.licencetype();
  30.             eddiestobart.licencetype();
  31.         }
  32.     }
  33.  
  34.  
  35.  
  36.  
  37.     class Vehicle
  38.     {
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.         public string type;
  46.         public int numwheels;
  47.         public double cost;
  48.         public double topspeed;
  49.  
  50.         public void licencetype()
  51.         {
  52.             // Console.WriteLine("Number of sides " + this.numberofsides);
  53.             //  Console.WriteLine("Side length " + this.sidelength);
  54.             //  Console.WriteLine("Regular? " + this.regular);
  55.  
  56.             if (this.type == "car")
  57.             {
  58.                 Console.WriteLine(this.type + " B");
  59.             }
  60.             if (this.type == "lorry")
  61.             {
  62.                 Console.WriteLine(this.type + " CE");
  63.             }
  64.             if (this.type == "motorcycle")
  65.             {
  66.                 Console.WriteLine(this.type + " A");
  67.             }
  68.         }
  69.  
  70.  
  71.     }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement