Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Car
- {
- private String name;
- public String brand;
- int hp;
- public Car(String name, String brand, int hp)
- {
- this.name = name;
- this.brand = brand;
- this.hp = hp;
- }
- public Car() {
- }
- public String getName()
- {
- return name;
- }
- public void setName(String name) {
- this.name = name;
- }
- }
- void Main()
- {
- Car fiat = new Car("punto", "fiat", 50);
- Car Ford = new Car("ka", "ford", 110);
- fiat.setName(Ford.getName());
- Console.WriteLine(fiat.getName());
- String horsepower = "75";
- int horse = Int32.Parse(horsepower);
- Console.WriteLine(horse);
- for (int i = 0; i<=5; i++){
- Console.WriteLine(i);
- }
- foreach (char letter in horsepower){
- Console.WriteLine(letter);
- }
- List<Car> list = new List<Car>();
- list.Add(Ford);
- Console.WriteLine(list[0].getName());
- String[] array = {"bil", "ford", "fiat"};
- Console.WriteLine(array[0]);
- Car bmw = new Car();
- bmw.setName("m3");
- Console.WriteLine(bmw.getName());
- try {
- }
- catch (Exception e) {
- Console.WriteLine(e);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement