Advertisement
Guest User

Untitled

a guest
Jun 19th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. class Car
  2. {
  3. private String name;
  4. public String brand;
  5. int hp;
  6.  
  7. public Car(String name, String brand, int hp)
  8. {
  9. this.name = name;
  10. this.brand = brand;
  11. this.hp = hp;
  12. }
  13.  
  14. public Car() {
  15.  
  16. }
  17.  
  18. public String getName()
  19. {
  20. return name;
  21. }
  22.  
  23. public void setName(String name) {
  24. this.name = name;
  25. }
  26.  
  27.  
  28. }
  29.  
  30.  
  31. void Main()
  32. {
  33. Car fiat = new Car("punto", "fiat", 50);
  34. Car Ford = new Car("ka", "ford", 110);
  35. fiat.setName(Ford.getName());
  36. Console.WriteLine(fiat.getName());
  37.  
  38. String horsepower = "75";
  39. int horse = Int32.Parse(horsepower);
  40. Console.WriteLine(horse);
  41.  
  42. for (int i = 0; i<=5; i++){
  43. Console.WriteLine(i);
  44. }
  45.  
  46. foreach (char letter in horsepower){
  47. Console.WriteLine(letter);
  48. }
  49.  
  50. List<Car> list = new List<Car>();
  51. list.Add(Ford);
  52. Console.WriteLine(list[0].getName());
  53.  
  54. String[] array = {"bil", "ford", "fiat"};
  55.  
  56. Console.WriteLine(array[0]);
  57.  
  58. Car bmw = new Car();
  59.  
  60. bmw.setName("m3");
  61.  
  62. Console.WriteLine(bmw.getName());
  63.  
  64.  
  65. try {
  66.  
  67. }
  68. catch (Exception e) {
  69. Console.WriteLine(e);
  70. }
  71.  
  72.  
  73.  
  74.  
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement