public interface ISeries {
int GetNext(); // return next number in series
void Reset(); // restart
void SetStart(int x); // set starting value
}
// Implement ISeries.
class ByTwos : ISeries {
int start;
int val;
public ByTwos() {
start = 0;
val = 0;
}
public int GetNext() {
val += 2;
return val;
}
public void Reset() {
val = start;
}
public void SetStart(int x) {
start = x;
val = start;
}
}
// Demonstrate the ISeries interface.
using System;
class SeriesDemo {
static void Main() {
ByTwos ob = new ByTwos();
for(int i=0; i < 5; i++)
Console.WriteLine("Next value is " + ob.GetNext());
Console.WriteLine("\nResetting");
ob.Reset();
for(int i=0; i < 5; i++)
Console.WriteLine("Next value is " + ob.GetNext());
Console.WriteLine("\nStarting at 100");
ob.SetStart(100);
for(int i=0; i < 5; i++)
Console.WriteLine("Next value is " +
ob.GetNext());
}
}
Why not? Do you not have the compiler? Does your computer crash when you try to run the compiler? Is the computer plugged in at the wall? Do you need to know the command to run the compiler? Is the compiler giving you an error? If so, on which line
and what is the error?
Also, I very strongly recommend that you download the book in my signature and start at chapter 1 (if you are really in a hurry then you can jump to chapter 3) for information on how to edit, compile and run a console application like the one you are showing.
Ok. You really must read the first three chapters of the book in my signature.
(I'm sorry, but it is getting too painful for me. I asked you three questions. You answered the first one and I had to beg for more information and then you answered the second one. I am not going to beg for the answer to the third question. Neither
am I going to tell you what your really fundamental problem is. If you don't help me, I don't help you, sorry)
when I run this program with the debug button it says
"There were built errors would you like to continue and run the last successful built"
My answer was
Yes
lastly the compiler the following message
Error 1 'SeriesDemo.ByTwos' does not implement interface member 'SeriesDemo.ISeries.SetStart()' C:\Users\lenovo\documents\visual studio 2010\Projects\scratch pad 2\SeriesDemo.cs 39 11 scratch pad 2
scratch_pad_2 is the name of the class containing the Main() method
when I compiled the program using the following command line the same output came up
'csc' is not recognised as an internal or external command,operable program or batch file
amigo 1
Member
60 Points
199 Posts
ompiling a progream
Apr 12, 2012 06:01 AM|LINK
I cannot compile the following program pls help?
public interface ISeries {
int GetNext(); // return next number in series
void Reset(); // restart
void SetStart(int x); // set starting value
}
// Implement ISeries.
class ByTwos : ISeries {
int start;
int val;
public ByTwos() {
start = 0;
val = 0;
}
public int GetNext() {
val += 2;
return val;
}
public void Reset() {
val = start;
}
public void SetStart(int x) {
start = x;
val = start;
}
}
// Demonstrate the ISeries interface.
using System;
class SeriesDemo {
static void Main() {
ByTwos ob = new ByTwos();
for(int i=0; i < 5; i++)
Console.WriteLine("Next value is " + ob.GetNext());
Console.WriteLine("\nResetting");
ob.Reset();
for(int i=0; i < 5; i++)
Console.WriteLine("Next value is " + ob.GetNext());
Console.WriteLine("\nStarting at 100");
ob.SetStart(100);
for(int i=0; i < 5; i++)
Console.WriteLine("Next value is " +
ob.GetNext());
}
}
Paul Linton
Star
13411 Points
2535 Posts
Re: ompiling a progream
Apr 12, 2012 06:04 AM|LINK
Why not? Do you not have the compiler? Does your computer crash when you try to run the compiler? Is the computer plugged in at the wall? Do you need to know the command to run the compiler? Is the compiler giving you an error? If so, on which line and what is the error?
You have to give us a bit more information!
amigo 1
Member
60 Points
199 Posts
Re: ompiling a progream
Apr 12, 2012 06:49 AM|LINK
Thank you for your answer
Actually whenever I try to open the specific command prompt for .net I find there is only one command area in windows7 with .net4
Also if I write the name of the program for compilation as
prog_name.csc
it is reporting that the interfaces are not available
Paul Linton
Star
13411 Points
2535 Posts
Re: ompiling a progream
Apr 12, 2012 06:53 AM|LINK
Is there particular reason for using a command prompt? There are many free GUI options http://www.microsoft.com/visualstudio/en-us/products/2010-editions/visual-web-developer-express is one.
How are you opening the command prompt? Can you show us the exact command that you type? Can you show us the exact error that you receive?
Paul Linton
Star
13411 Points
2535 Posts
Re: ompiling a progream
Apr 12, 2012 06:57 AM|LINK
Also, I very strongly recommend that you download the book in my signature and start at chapter 1 (if you are really in a hurry then you can jump to chapter 3) for information on how to edit, compile and run a console application like the one you are showing.
amigo 1
Member
60 Points
199 Posts
Re: ompiling a progream
Apr 12, 2012 07:05 AM|LINK
I type
cmd.exe
in the Run program dialog box as ther was no other alternative
Paul Linton
Star
13411 Points
2535 Posts
Re: ompiling a progream
Apr 12, 2012 07:06 AM|LINK
and ... ?
amigo 1
Member
60 Points
199 Posts
Re: ompiling a progream
Apr 12, 2012 07:17 AM|LINK
and when the window opens
I typed
prog _ name .csc
for I may not bring the control ti the directory as C#4 detects it automatically
Paul Linton
Star
13411 Points
2535 Posts
Re: ompiling a progream
Apr 12, 2012 07:21 AM|LINK
Ok. You really must read the first three chapters of the book in my signature.
(I'm sorry, but it is getting too painful for me. I asked you three questions. You answered the first one and I had to beg for more information and then you answered the second one. I am not going to beg for the answer to the third question. Neither am I going to tell you what your really fundamental problem is. If you don't help me, I don't help you, sorry)
amigo 1
Member
60 Points
199 Posts
Re: ompiling a progream
Apr 13, 2012 06:24 AM|LINK
when I run this program with the debug button it says
"There were built errors would you like to continue and run the last successful built"
My answer was
Yes
lastly the compiler the following message
Error 1 'SeriesDemo.ByTwos' does not implement interface member 'SeriesDemo.ISeries.SetStart()' C:\Users\lenovo\documents\visual studio 2010\Projects\scratch pad 2\SeriesDemo.cs 39 11 scratch pad 2
scratch_pad_2 is the name of the class containing the Main() method
when I compiled the program using the following command line the same output came up
'csc' is not recognised as an internal or external command,operable program or batch file