Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Program10._1
- {
- abstract class Statek
- {
- protected static int licznik = 0;
- protected int numerStatku;
- protected string typ;
- protected double predkoscMax;
- public abstract int oblicz_zanurzenie();
- public void info_ogolne()
- {
- Console.WriteLine("Numer Statku Typ Statku Prędkość Maksymalna");
- Console.Write(" {0:D3}", numerStatku);
- Console.Write(" " + typ + " ");
- Console.WriteLine(" {0:F2}", predkoscMax);
- }
- }
- class Jacht : Statek
- {
- int dlugosc;
- double powZagli;
- Jacht(string t, double pM, int d, double pZ)
- {
- Console.WriteLine("Konstruktor klasy Jacht o 4 argumentach");
- numerStatku = licznik++;
- typ = t;
- predkoscMax = pM;
- dlugosc = d;
- powZagli = pZ;
- }
- public override int oblicz_zanurzenie()
- {
- int a;
- a = (int)(predkoscMax * 100 / (3 * dlugosc));
- return a;
- }
- public void info_jachtu()
- {
- Console.WriteLine("Długość jachtu: {0:F2} metrów", dlugosc);
- Console.WriteLine("Zanurzenie: {0} centymetrów", oblicz_zanurzenie());
- }
- public static void Main()
- {
- Jacht jolka = new Jacht("Rybka", 6.7, 4, 10.5);
- jolka.info_ogolne();
- jolka.info_jachtu();
- JachtPelnomorski jp = new JachtPelnomorski("Drowning Daisy", 10, 6, 12);
- jp.info_ogolne();
- jp.info_jachtu();
- jp.Bar();
- Console.ReadLine();
- }
- }
- public sealed class JachtPelnomorski : Jacht
- {
- // Wlasne pole
- int foo = 5;
- JachtPelnomorski(string t, double pM, int d, double pZ)
- {
- base(t, pM, d, pZ);
- Console.WriteLine("Konstruktor klasy JachtPelnomorski o 4 argumentach");
- }
- // Wlasna metoda
- public void Bar()
- {
- Console.WriteLine("JachtPelnomorski::Bar foo={0}", foo);
- }
- // Inna metoda na zanurzenie.
- public override int oblicz_zanurzenie()
- {
- return (int)(predkoscMax * 50 / (3 * dlugosc));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement