Advertisement
damesova

BikeProject

Oct 4th, 2022
686
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.31 KB | None | 0 0
  1. // Main
  2.  
  3. namespace BikeProject
  4. {
  5.     public class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             Bike bik4e1 = new Bike("Drag", "Al", 21);
  10.             Console.WriteLine("bik4e1 before:" + bik4e1.getBrand());
  11.  
  12.             bik4e1.relaceBrand("Drag1");
  13.             Console.WriteLine("bik4e1 after:" + bik4e1.getBrand());
  14.  
  15.             Bike bik4e2 = new Bike("BMX", "Plastic", 3);
  16.             Console.WriteLine("bik4e2 before:" + bik4e2.getBrand());
  17.  
  18.             bik4e2.relaceBrand("BMX1");
  19.             Console.WriteLine("bik4e2 after:" + bik4e2.getBrand());
  20.         }
  21.     }
  22. }
  23.  
  24. //Class Bike
  25.  
  26. using System;
  27. using System.Collections.Generic;
  28. using System.Linq;
  29. using System.Text;
  30. using System.Threading.Tasks;
  31.  
  32. namespace BikeProject
  33. {
  34.     public class Bike
  35.     {
  36.  
  37.         private string Brand;
  38.         private string Material;
  39.         private int Speeds;
  40.  
  41.         public Bike(string brandP, string materialP, int speedsP)
  42.         {
  43.             this.Brand = brandP;
  44.             this.Material = materialP;
  45.             this.Speeds = speedsP;
  46.         }
  47.  
  48.         public string getBrand()
  49.         {
  50.             return this.Brand;
  51.         }
  52.  
  53.         public void relaceBrand(string newBrand)
  54.         {
  55.             this.Brand = newBrand;
  56.         }
  57.  
  58.        
  59.  
  60.     }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement