Advertisement
Guest User

Ajance (C# Shell App Paste)

a guest
Mar 28th, 2020
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 14.42 KB | None | 0 0
  1. //Disclaimer: The creator of 'C# Shell (C# Offline Compiler)' is in no way responsible for the code posted by any user.
  2. using System;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Collections.Generic;
  6.  
  7. namespace CSharp_Shell{
  8.     public class Company{
  9.         private List<Employee>ListEmployee;
  10.         Company(){
  11.             ListEmployee=new List<Employee>();
  12.             ListEmployee.Add(new Employee{Id=1,Name="Abdullah",Gender="Male",Experince=7,Salary=30000});
  13.             ListEmployee.Add(new Employee{Id=1,Name="Aya",Gender="Female",Experince=6,Salary=25000});
  14.             ListEmployee.Add(new Employee{Id=1,Name="Abdelkader",Gender="Male",Experince=5,Salary=300000});
  15.             ListEmployee.Add(new Employee{Id=1,Name="Hanaa",Gender="Female",Experince=4,Salary=20000});
  16.         }
  17.        
  18.     }
  19.    
  20.  class Employee{
  21.     string name;
  22.     int id;
  23.     int experince;
  24.     int salary;
  25.     string gender;
  26.    
  27.     public string Name{
  28.         get{
  29.        
  30.             return gender;
  31.         }
  32.            
  33.         set{name=value;}
  34.    
  35.     }
  36.     public enum Gendero{
  37.         Male,
  38.         Female,
  39.         Unkmnow,
  40.     }
  41.     public string Gender{
  42.         get{
  43.        
  44.             return gender;}
  45.         set{gender=value;}
  46.     }
  47.    
  48.     public int Id{
  49.         get{return id;}
  50.         set{id=value;}
  51.     }
  52.    
  53.     public int Experince{
  54.         get{return experince;}
  55.         set{experince=value;}
  56.     }
  57.     public  int Salary{
  58.         get{return salary;}
  59.         set{value=salary;}
  60.     }
  61.  public static void EmoloyeeData(List<Employee>e){
  62.     foreach(Employee employee in e){
  63.         Console.WriteLine(employee.Name);
  64.     }
  65.  }
  66.      public static void prompotoemployee(List<Employee> employeelist,Ispromotable Is){
  67.         foreach(Employee employee in employeelist){
  68.             if(Is(employee)){
  69.                 employee.Salary+=5000;
  70.                
  71.                 Console.WriteLine(employee.Name+" Promoto  ");
  72.                
  73.             }
  74.         }
  75.     }
  76. }
  77. //*********************End Class Employee*********************************//
  78.  
  79. delegate bool Ispromotable(Employee emp);
  80.  
  81. abstract class  Salary{
  82. public abstract int salary(int x);
  83.  
  84.      
  85.      
  86.  }
  87. class Customer:Salary{
  88.      string name;
  89.      string adress;
  90.      string phone;
  91.      string id;
  92.      int age;
  93.    public override int salary(int x){
  94.         int result=x;
  95.         return result;
  96.      }
  97.         public string Name{
  98.            
  99.             get{return name;}
  100.             set{name=value;}
  101.         }
  102.        
  103.         public int Age{
  104.            
  105.             get{return age;}
  106.             set{age=value;}
  107.         }
  108.        
  109.         public string Adress{
  110.            
  111.             get{return adress;}
  112.             set{adress=value;}
  113.         }
  114.         public string Phone{
  115.            
  116.             get{return phone;}
  117.             set{phone=value;}
  118.         }
  119.         public string Id{
  120.            
  121.             get{return id;}
  122.             set{id=value;}
  123.         }
  124.  
  125.         public void EnterData(){
  126.             go:
  127.             Console.WriteLine("Please Enter Youre Name");
  128.             Name=Console.ReadLine();
  129.             Console.WriteLine("Please Enter Youre Adress");
  130.             Adress=Console.ReadLine();
  131.             Console.WriteLine("Please Enter Youre Phone");
  132.             Phone=Console.ReadLine();
  133.             Console.WriteLine("Please Enter Youre Id");
  134.             Id=Console.ReadLine();
  135.             Console.WriteLine("Please Enter Youre Age");
  136.             Age=int.Parse(Console.ReadLine());
  137.             if(Age>=22){
  138.                 Console.WriteLine(" Accepted");
  139.                 Console.WriteLine("  ");
  140.             }else{
  141.                
  142.                 Console.WriteLine("Not Accepted");
  143.                
  144.                 goto go;
  145.             }
  146.         }
  147.         public void ShowData(){
  148.             Console.WriteLine("Name :{0}",Name);
  149.             Console.WriteLine("Adress :{0}",Adress);
  150.             Console.WriteLine("Phone :{0}",Phone);
  151.             Console.WriteLine("Id :{0}",Id);
  152.             Console.WriteLine("Age :{0}",Age);
  153.             // use abstrac class
  154.             //Console.WriteLine("Salary  :{0}  ",salary(30000));
  155.            
  156.         }
  157.        
  158.    
  159. interface   I1{
  160.     bool start(bool x);
  161.     void Fore();
  162.     void back();
  163.     void right();
  164.     void left();
  165. }
  166. interface I2{
  167.     bool start(bool x);
  168.     void Fore();
  169.     void back();
  170.     void right();
  171.     void left();
  172. }
  173. class Car:I1,I2{
  174.    
  175. protected string prand;
  176. protected string name;
  177. protected int speed;
  178. protected string color;
  179. protected int price;
  180. bool I1.start(bool val){
  181.    
  182.    
  183.  
  184.     bool result=val;
  185.     if(result== true){
  186.         Console.WriteLine("Car Is On");
  187.     }else{Console.WriteLine("Car is Close");}
  188.     return result;
  189.    
  190. }
  191.  void I1.Fore(){
  192.     Console.WriteLine("Care Is Fore In The Ground");
  193. }
  194.  void I1.back(){
  195.     Console.WriteLine("Csr Is Back In The Ground");
  196.    
  197. }
  198.  void I1.right(){
  199.     Console.WriteLine(" Car Is Right In The Ground");
  200. }
  201.  void I1.left(){
  202.     Console.WriteLine("Car Is Left In The Ground");
  203. }
  204. bool I2.start(bool val){
  205.    
  206.    
  207.  
  208.     bool result=val;
  209.     if(result== true){
  210.         Console.WriteLine("Car Is On");
  211.     }else{Console.WriteLine("Car is Close");}
  212.     return result;
  213.    
  214. }
  215.  void I2.Fore(){
  216.     Console.WriteLine("Care Is Fore In The Air");
  217. }
  218.  void I2.back(){
  219.     Console.WriteLine("Csr Is Back In The Air");
  220.    
  221. }
  222.  void I2.right(){
  223.     Console.WriteLine(" Car Is Right In The Air");
  224. }
  225.  void I2.left(){
  226.     Console.WriteLine("Car Is Left In The Air");
  227. }
  228.  
  229.  
  230.  
  231. public void Type(){
  232.     Console.WriteLine("1.Bmw");
  233.     Console.WriteLine("2.Fiate");
  234.     Console.WriteLine("3.Marcides");
  235.    
  236.     Console.WriteLine("Enter the nurber of the car if you want to view the details of this car");
  237.    
  238.    
  239. }
  240.     public string Name{
  241.         get{return name;}
  242.         set{value=name;}
  243.     }
  244.     public int Speed{
  245.         get{ return speed;}
  246.         set{ speed=value;}
  247.     }
  248.     public string Color{
  249.         get{return color;}
  250.         set{color=value;}
  251.     }
  252.     public int Price{
  253.         get{return price;}
  254.         set{ price=value;}
  255.     }
  256.     public string Prand{
  257.         get{return prand;}
  258.         set{prand=value;}
  259.     }
  260.    
  261.     public void Bmw(){}
  262.    
  263.     public Car(string _name,string _color,string _prand,int _speed,int _price){
  264.         name=_name;
  265.         color=_color;
  266.         prand=_prand;
  267.         speed=_speed;
  268.         price=_price;
  269.        
  270.     }
  271. //  public Car(string _name):this(null,0,0,string _name){
  272. //  name=_name;
  273. //  }
  274.     public Car(string _name,string _color,int _speed){
  275.         name=_name;
  276.         color=_color;
  277.         speed=_speed;
  278.         price=0;
  279.     }
  280.    
  281.     public Car(string _name,string _color){
  282.         name=_name;
  283.         color=_color;
  284.         speed=0;
  285.         price=0;
  286.     }
  287.     public Car(string _name){
  288.         name=_name;
  289.         color=null;
  290.         speed=0;
  291.         price=0;
  292.     }
  293.    
  294.    
  295.    
  296.     public Car(){
  297.    
  298.     }
  299.    
  300.     public void details(){
  301.         Console.WriteLine(" Nmae  :"+Name);
  302.         Console.WriteLine("Color  :"+Color);
  303.         Console.WriteLine("Brand  :"+Prand);
  304.         Console.WriteLine("Speed  :"+Speed);
  305.         Console.WriteLine("Price  :"+Price+"$");
  306.     }
  307.    
  308. }
  309. class Bmw:Car{
  310.    
  311.    
  312.    
  313.     public Bmw(string _name,string _color,string _prand,int _speed,int _price){
  314.         name=_name;
  315.         color=_color;
  316.         prand=_prand;
  317.         speed=_speed;
  318.         price=_price;
  319.        
  320.     }
  321. //  public Car(string _name):this(null,0,0,string _name){
  322.     //  name=_name;
  323. //  }
  324.     public Bmw(string _name,string _color,int _speed){
  325.         name=_name;
  326.         color=_color;
  327.         speed=_speed;
  328.         price=0;
  329.     }
  330.    
  331.     public Bmw(string _name,string _color){
  332.         name=_name;
  333.         color=_color;
  334.         speed=0;
  335.         price=0;
  336.     }
  337.     public Bmw(string _name){
  338.         name=_name;
  339.         color=null;
  340.         speed=0;
  341.         price=0;
  342.     }
  343.    
  344.    
  345.    
  346.     public Bmw(){
  347.    
  348.     }
  349.  
  350. }
  351. class Fiat:Car{
  352.    
  353.     public Fiat(string _name,string _color,string _prand,int _speed,int _price){
  354.         name=_name;
  355.         color=_color;
  356.         prand=_prand;
  357.         speed=_speed;
  358.         price=_price;
  359.        
  360.     }
  361.     /*public Car(string _name):this(null,0,0,string _name){
  362.     name=_name;
  363.     }*/
  364.     public Fiat(string _name,string _color,int _speed){
  365.         name=_name;
  366.         color=_color;
  367.         speed=_speed;
  368.         price=0;
  369.     }
  370.    
  371.     public Fiat(string _name,string _color){
  372.         name=_name;
  373.         color=_color;
  374.         speed=0;
  375.         price=0;
  376.     }
  377.     public Fiat(string _name){
  378.         name=_name;
  379.         color=null;
  380.         speed=0;
  381.         price=0;
  382.     }
  383.    
  384.    
  385.    
  386.     public Fiat(){
  387.    
  388.     }
  389.    
  390. }  
  391. class Marcides:Car{
  392.    
  393.    
  394.     public Marcides(string _name,string _color,string _prand,int _speed,int _price){
  395.         name=_name;
  396.         color=_color;
  397.         prand=_prand;
  398.         speed=_speed;
  399.         price=_price;
  400.        
  401.     }
  402. /*  public Car(string _name):this(null,0,0,string _name){
  403.         name=_name;
  404.     }*/
  405.     public Marcides(string _name,string _color,int _speed){
  406.         name=_name;
  407.         color=_color;
  408.         speed=_speed;
  409.         price=0;
  410.     }
  411.    
  412.     public Marcides(string _name,string _color){
  413.         name=_name;
  414.         color=_color;
  415.         speed=0;
  416.         price=0;
  417.     }
  418.     public Marcides(string _name){
  419.         name=_name;
  420.         color=null;
  421.         speed=0;
  422.         price=0;
  423.     }
  424.    
  425.    
  426.    
  427.     public Marcides(){
  428.    
  429.     }
  430.    
  431.    
  432.    
  433. }
  434. class Tsla:Car{
  435.    
  436.    
  437.    
  438.     public Tsla(string _name,string _color,string _prand,int _speed,int _price){
  439.         name=_name;
  440.         color=_color;
  441.         prand=_prand;
  442.         speed=_speed;
  443.         price=_price;
  444.        
  445.     }
  446.     /*public Car(string _name):this(null,0,0,string _name){
  447.         name=_name;
  448.    
  449. }*/
  450.     public Tsla(string _name,string _color,int _speed){
  451.         name=_name;
  452.         color=_color;
  453.         speed=_speed;
  454.         price=0;
  455.     }
  456.    
  457.     public Tsla(string _name,string _color){
  458.         name=_name;
  459.         color=_color;
  460.         speed=0;
  461.         price=0;
  462.     }
  463.     public Tsla(string _name){
  464.         name=_name;
  465.         color=null;
  466.         speed=0;
  467.         price=0;
  468.     }
  469.    
  470.    
  471.    
  472.     public Tsla(){
  473.    
  474.     }
  475. }
  476.  
  477.  
  478.     public static class Program
  479.     {
  480.         public static void Main(){
  481.            
  482.        {
  483.        
  484.             char p;
  485.             bool val=true;
  486.             Console.ForegroundColor=ConsoleColor.Green;
  487.          
  488.           Customer c=new Customer();
  489.           Car c1=new Car();
  490.             Bmw b=new Bmw("Bmw","Black","Bmw22",500,1000000);
  491.             Tsla t=new Tsla("Tsal","White","Tsla220",600,250000);
  492.          
  493.             Fiat f=new Fiat("Fiat","White","Fiat2344",400,500000);
  494.              Marcides r=new Marcides("Marcides","red","Marcides55",300,300000);
  495.              
  496.              do{
  497.              Console.WriteLine("  Sair In Our Ajance");
  498.              Console.WriteLine("Please Choicese Nurber");
  499.              Console.WriteLine("1.Enter My Data");
  500.              Console.WriteLine("2.Show My Data");
  501.              Console.WriteLine("3.Type Cars");
  502.              Console.WriteLine("4.Test"+ " >>>>> Not Complete ");
  503.               Console.WriteLine("5.Employee"+" >>>>>> "+"Not Complete");
  504.              Console.WriteLine("6.Exite");
  505.              int n=int.Parse(Console.ReadLine());
  506.              switch(n){
  507.              case 1:
  508.              Console.Clear();
  509.              c.EnterData();
  510.              Console.WriteLine("Do you want retun any Event Y/N!?");
  511.              p=char.Parse(Console.ReadLine());
  512.              if(p=='Y'){
  513.                 Console.Clear();
  514.                 val=true;
  515.              }else{Console.Clear();
  516.                 val=false;
  517.                 goto s;
  518.              }
  519.                
  520.              break;
  521.                 Console.Clear();
  522.                 case 2:
  523.                 Console.Clear();
  524.                 c.ShowData();
  525.                 Console.WriteLine("Do you want retun any Event Y/N!?");
  526.              p=char.Parse(Console.ReadLine());
  527.              if(p=='Y'){
  528.                 Console.Clear();
  529.                 val=true;
  530.              }else{Console.Clear();
  531.                 val=false;
  532.                 goto s;
  533.              }
  534.                
  535.              break;
  536.              
  537.              case 3:
  538.              bool Vale=true;
  539.              char k;
  540.              Console.Clear();
  541.          do{    
  542.     Console.WriteLine("1.Bmw");
  543.     Console.WriteLine("2.Fiate");
  544.     Console.WriteLine("3.Marcides");
  545.     Console.WriteLine("4.Tsla");
  546.    
  547.     Console.WriteLine("Enter the nurber of the car if you want to view the details of this car");
  548.     int no=int.Parse(Console.ReadLine());
  549.     //ineer Switc
  550.    
  551.     switch(no){
  552.     case 1:
  553.     ///}}}}}}
  554.     Console.Clear();
  555.     Console.WriteLine("1-Details");
  556.     Console.WriteLine("2-Test");
  557.     int nu=int.Parse(Console.ReadLine());
  558.    
  559.    
  560.    
  561.     b.details();
  562.     Console.WriteLine("Do You Want To return  ");
  563.     k=char.Parse(Console.ReadLine());
  564.     if(k=='Y'){
  565.     Console.Clear();
  566.         Vale=true;
  567.     }else{Console.Clear();
  568.         Vale=false;}
  569.    break;
  570.    
  571.    
  572.    ////////
  573.    case 2:
  574.    
  575.   Console.Clear();
  576.            f.details();
  577.            Console.WriteLine("Do You Want To return  ");
  578.     k=char.Parse(Console.ReadLine());
  579.     if(k=='Y'){
  580.         Console.Clear();
  581.         Vale=true;
  582.     }else{Console.Clear();
  583.         Vale=false;}
  584.           break;
  585.        case 3:
  586.        Console.Clear();
  587.        r.details();
  588.        Console.WriteLine("Do You Want To return  ");
  589.     k=char.Parse(Console.ReadLine());
  590.     if(k=='Y'){
  591.         Console.Clear();
  592.         Vale=true;
  593.     }else{Console.Clear();
  594.         Vale=false;}
  595.        break;
  596.        case 4:
  597.        Console.Clear();
  598.        t.details();
  599.        Console.WriteLine("Do You Want To return  ");
  600.     k=char.Parse(Console.ReadLine());
  601.     if(k=='Y'){
  602.         Console.Clear();
  603.         Vale=true;
  604.     }else{Console.Clear();
  605.         Vale=false;}
  606.        break;
  607.        
  608.        default:
  609.        Console.WriteLine("  Are you stupid I'r saying you choose a nurber of choices");
  610.            
  611.        Console.WriteLine("Do You Want To retun Y/N!?");
  612.      
  613.     k=char.Parse(Console.ReadLine());
  614.     if(k=='Y'){
  615.         Console.Clear();
  616.         Vale=true;
  617.     }else{Console.Clear();
  618.         Vale=false;}
  619.        
  620.                    
  621.             Console.WriteLine("Do You Want To retun Y/N!?");
  622.              p=char.Parse(Console.ReadLine());
  623.              if(p=='Y'){
  624.                 Console.Clear();
  625.                 val=true;
  626.              }else{Console.Clear();
  627.                 val=false;
  628.                 goto s;
  629.              }
  630.             Console.WriteLine("GodLuck Sair");
  631.        
  632.        break;
  633.         }
  634.          }while(Vale);
  635.            
  636.              
  637.        
  638.        break;
  639.        case 4:  
  640.        Console.Clear();
  641.        I1 i=new Car();
  642.       i.Fore();
  643.       Car c8=new Car();
  644.       ((I1)c8).back();
  645.       I2 a=new Car();
  646.       a.right();
  647.       ((I2)a).left();
  648.       i.start(true);
  649.       a.start(false);
  650.        break;
  651.        case 5:
  652.        Console.Clear();
  653.        List<Employee>emp=new List<Employee>();
  654.   emp.Add(new Employee{Id=10,Name="Abdullah",Salary=30000,Experince=7});
  655.        
  656.       emp.Add(new Employee{Id=11,Name="Abdelkader",Salary=250000,Experince=6});
  657.      
  658.       emp.Add(new Employee{Id=12,Name="Ahmed",Salary=20000,Experince=5});
  659.          
  660.       emp.Add(new Employee{Id=13,Name="Mazen",Salary=15000,Experince=4});
  661.        
  662.      
  663.       emp.Add(new Employee{Id=14,Name="Khaled",Salary=10000,Experince=3});
  664.    static bool promoto(Employee e){
  665.         if(e.Experince>=5){
  666.             return true;
  667.         }else{
  668.             return false;
  669.    }
  670.     }
  671.      
  672.      
  673.       Ispromotable Is=new Ispromotable(promoto);
  674.       Employee.prompotoemployee(emp,Is);
  675.        
  676.        break;
  677.       case 6:
  678.      
  679.              s:
  680.              Console.Clear();
  681.              
  682.              Console.WriteLine("Goud Luck Sair...");
  683.              val=false;
  684.              
  685.              break;
  686.              default:
  687.              Console.Clear();
  688.             Console.WriteLine("  Are you stupid I'r saying you choose a nurber of choices");
  689.            
  690.             Console.WriteLine("Do You Want To retun Y/N!?");
  691.              p=char.Parse(Console.ReadLine());
  692.              if(p=='Y'){
  693.                 Console.Clear();
  694.                 val=true;
  695.              }else{Console.Clear();
  696.                 val=false;
  697.                 goto s;
  698.              }
  699.            Console.WriteLine("GodLuck Sair");
  700.              break;
  701.              
  702.              }
  703.              }while(val);
  704.          
  705.              
  706.            
  707.             // Use Interfase
  708.   int[] values=(int[])Enum.GetValues(typeof(Gender));
  709.   //foreach(int val in values ){
  710.   //    Console.WriteLine(val);
  711.  // }
  712.   string []nam=Enum.GetNames(typeof(Gender));
  713.   foreach(string name in nam){
  714.     Console.WriteLine(name);
  715.   }
  716.  
  717.  
  718.         }
  719.      
  720.    
  721.    
  722.  
  723.      
  724.    //Employee.EmoloyeeData();
  725.  
  726.        }
  727.        public enum Gender{
  728.         UnKnow=0,
  729.         Male=1,
  730.         Female=2
  731.        }
  732.        
  733.         }
  734. }
  735. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement