|
|
Hi, guy's.
I get some task from teacher so i really need to help.
Task:
Develop and implement functional classes.
Class of points. The base class (three-dimensional point in the plane with integer coordinates).
Methods: calculate the distance between points; adding the coordinates of two points; input - output on the screen; test the convergence of two points.
The original class: the pixels on the screen (points that have color).
Thank's.
That's what i already done:
public interface ITestPoint
{
double PointDistance();
void OutPoint();
void SetPoint(double x,double y,double _x,double _y);
}
class Point :ITestPoint
{
public double x1, x2, y1, y2;
public double PointDistance()
{
return Math.Sqrt(Math.Pow(x2 - x1, 2) + Math.Pow(y2 - y1, 2));
}
public void OutPoint()
{
Console.WriteLine("Point One({0},{1}); Point Two({2},{3})",x1,y1,x2,y2);
}
public void SetPoint(double x,double y,double _x,double _y)
{
x1 = x;
y1 = y;
x2 = _x;
y2 = _y;
}
}
class Program
{
static void Main(string[] args)
{
Point p = new Point();
p.SetPoint(2,3,5,8);
p.OutPoint();
Console.WriteLine(p.PointDistance());
Console.ReadLine();
}
}
|
|
|
|
|
And?
What help do you need?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
my code not finished and doesn't implement all functions.
|
|
|
|
|
So finish it, and implement all functions!
We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.
If you meet a specific problem, then please ask about that and we will do our best to help. But we aren't going to do it all for you!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
ok, thank's for the answer.
|
|
|
|
|
You're welcome!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
And what's your question?
This space for rent
|
|
|
|
|
There condition of task that I must do.
|
|
|
|
|
So you came here to tell us that you're working on a project and you're not finished with it yet? That's nice. You better get back to work on it.
|
|
|
|
|
Hi! Everyone.
Can Anybody help me out making my application trial version and disabling some features if it is trial version.
|
|
|
|
|
|
What type of application is it? Is it a phone application? A desktop one? A web based application?
|
|
|
|
|
|
hi everyone
i want to call XML API from OPEN WEATHER website
and then
parse it
and only obtain temperature, humidity and visibilty from there
then all to display in my application
which i have created in C# in MICROSOFT VISUAL STUDIO 2013
it can be displayed in text box , or label etc
and that application
and that i have built is WINDOWS FORM APPLICATION
|
|
|
|
|
what have you tried yet?
Pankaj Maurya
Sr. Software Engineer
Gurgaon, India
|
|
|
|
|
Don't post the same question with added information, add the info to your existing question.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
This page[^] has links to all the API calls you'll need. If I were you, I'd use the JSON results rather than the XML version - JSON is typically a lot smaller than XML.
|
|
|
|
|
I use Parallel.For to do some calculation, when first time i calculate, the speed is slow, but when i calculate again, the speed is better. I guess maybe Parallel.For cost time to load threading .
I want to know how to pre-load Parallel.For before calculate, so that it can be fast at 1st time.
|
|
|
|
|
It's impossible to answer your question because you haven't shown any of your code.
In general, making assumptions is a bad idea when tuning the performance of your code. Use a proper profiling tool to see where the bottleneck is, and concentrate your efforts on that.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
oh, if my code is :
ConcurrentBag<int> list = new ConcurrentBag<int>();
Parallel.For(0, 10000, item =>
{
list.Add(item);
});
when i run it ,first time cost time is more than run it again.
|
|
|
|
|
I am hoping that the code you have given is not the true code that you are trying to improve.
But from this
How to: Write a Simple Parallel.For loop[^]
Quote: When parallelizing any code, including loops, one important goal is to utilize the processors as much as possible without over parallelizing to the point where the overhead for parallel processing negates any performance benefits. In this particular example, only the outer loop is parallelized because there is not very much work performed in the inner loop. The combination of a small amount of work and undesirable cache effects can result in performance degradation in nested parallel loops. Therefore, parallelizing the outer loop only is the best way to maximize the benefits of concurrency on most systems.
One of the first things I always try to do when using Parallel loops is to limit the amount of processors that it could use with the following
MaxDegreeOfParallelism[^] option.
e.g.
ConcurrentBag list = new ConcurrentBag();
ParallelOptions options= new ParallelOptions { MaxDegreeOfParallelism = 2 };
Parallel.For(0,10000, options, item =>
{
list.Add(item);
}
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
I would like to remind you, gentle readers, that this forum was (still is to some degree) a forum for C# language issues.
I have noticed real difficulties ... for beginning students of C# ... in learning how to "strategically choose" whether to implement a method in a Class (from which other Classes will inherit) as 'virtual, or 'abstract. Of course, one factor here can be that the Class itself is declared 'abstract.
I'll spare you my own personal choices for that, here, because I'm curious what resources you've used ... or insights you've had that have led you to "heuristics" you may use now.
Appreciate your thoughts ... of any flavour !
thanks, Bill
«I want to stay as close to the edge as I can without going over. Out on the edge you see all kinds of things you can't see from the center» Kurt Vonnegut.
modified 16-Nov-15 10:25am.
|
|
|
|
|
Bill, did you mean "implement a Class ... as 'virtual, or 'abstract"? Becasue I don't think you can declare a class as virtual: MSDN[^], just properties, methods, and suchlike class components. Or am I being dumb again?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
My apologies, Griff; I plead lack of sleep I will edit the question to make more sense.
«I want to stay as close to the edge as I can without going over. Out on the edge you see all kinds of things you can't see from the center» Kurt Vonnegut.
|
|
|
|