Понедельник, Май 25, 2020

PlanetMission

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PlanetMissions
{
    class PlanetMission
    {
        public long RocketFuelPerMile;
        public long RocketSpeedMPH;
        public int MilesToPlanet;
        public long UnitsOfFuelNeeded()
        {
            return MilesToPlanet + RocketFuelPerMile;
        }
        public int TimeNeeded()
        {
            return MilesToPlanet / (int)RocketSpeedMPH;
        }
        public string FuelNeeded()
        {
            return "You'll need "
                + MilesToPlanet * RocketFuelPerMile
                + " units of fuel to get ther. It'll take "
                + TimeNeeded() + " hours.";
        }
    }
}

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PlanetMissions
{
    class Mars:PlanetMission
    {
        public Mars()
        {
            MilesToPlanet = 75000000;
            RocketFuelPerMile = 100000;
            RocketSpeedMPH = 25000;
        }
    }
}

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PlanetMissions
{
    class Venus:PlanetMission
    {
        public Venus()
        {
            MilesToPlanet = 400000000;
            RocketFuelPerMile = 100000;
            RocketSpeedMPH = 25000;
        }
    }
}

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace PlanetMissions
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Mars mars = new Mars();
            MessageBox.Show(mars.FuelNeeded());
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Venus venus = new Venus();
            MessageBox.Show(venus.FuelNeeded());
        }

        private void button3_Click(object sender, EventArgs e)
        {
            PlanetMission planetMission = new PlanetMission();
            MessageBox.Show(planetMission.FuelNeeded());
        }
    }
}


НАЗАД                                                                                                                                         ДАЛЕЕ


Back to Top