Hey!
Just joined this site out of what one might call desperation.
I am doing an assignment and have very limited time left to do it, im doing night Courses on top of my Daily job. And have lately been very overworked, no rest for the wicked.
But i recently started a coding course, and this assignment is kind of kicking my butt.
The assignment is as follows;
I need to create a program that calculates the top speed of a veichle using one input, horsepower. The math is irrelevant. Its just a made up formula.
So im meant to store the horsepower, apply that to a random formula, and then send that information back to the user. After this has been completed I need to inherit the qualities of my first class. I.E the veichle onto Another class called "Truck". And then perform a different b.s formula with the addition of weight to it. The idea is to specifically use the inhertiance feature of VS studios to do this. But I feel like im missing so much more.
I am in the middle of Writing the code, and my brain just seems to have frozen. Included is the code im working on, any kind of help would be greatly appreciated.
Just joined this site out of what one might call desperation.
I am doing an assignment and have very limited time left to do it, im doing night Courses on top of my Daily job. And have lately been very overworked, no rest for the wicked.
But i recently started a coding course, and this assignment is kind of kicking my butt.
The assignment is as follows;
I need to create a program that calculates the top speed of a veichle using one input, horsepower. The math is irrelevant. Its just a made up formula.
So im meant to store the horsepower, apply that to a random formula, and then send that information back to the user. After this has been completed I need to inherit the qualities of my first class. I.E the veichle onto Another class called "Truck". And then perform a different b.s formula with the addition of weight to it. The idea is to specifically use the inhertiance feature of VS studios to do this. But I feel like im missing so much more.
I am in the middle of Writing the code, and my brain just seems to have frozen. Included is the code im working on, any kind of help would be greatly appreciated.
C#:
namespace Fordonen
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Var god ange antalet hästkrafter; ");
int horsepower = int.Parse(Console.ReadLine());
Console.WriteLine("Ange färgen på ditt fordon; ");
string color = Console.ReadLine();
Console.WriteLine("Ange nu vikten på ditt fordon; ");
int weight = int.Parse(Console.ReadLine());
Fordon f = new Fordon(horsepower, color, weight); //skapa nytt objekt med parametrar som konstruktorn tar emot.
f.PrintData();
}
}
public class Fordon
{
public Fordon(int a, string b, int c)
{
horsepower = a; color = b; weight = c;
} //Detta är konstruktorn, den anropas när objektet skapas
public void PrintData()
{
Console.WriteLine("hästkrafter: {0}, color: {1}, weight {3}", horsepower, color, weight);
}
private int horsepower;
private string color;
private int _horsepower;
private int weight;
}
}