Click here to Skip to main content
15,889,631 members
Home / Discussions / C#
   

C#

 
GeneralRe: Abstract Class Pin
future383924-Apr-10 16:48
future383924-Apr-10 16:48 
GeneralRe: Abstract Class Pin
future383924-Apr-10 21:22
future383924-Apr-10 21:22 
GeneralRe: Abstract Class Pin
OriginalGriff24-Apr-10 21:29
mveOriginalGriff24-Apr-10 21:29 
GeneralRe: Abstract Class Pin
DaveyM6924-Apr-10 22:53
professionalDaveyM6924-Apr-10 22:53 
GeneralRe: Abstract Class Pin
Eddy Vluggen24-Apr-10 22:56
professionalEddy Vluggen24-Apr-10 22:56 
GeneralRe: Abstract Class Pin
future383925-Apr-10 13:45
future383925-Apr-10 13:45 
GeneralRe: Abstract Class Pin
future383925-Apr-10 17:06
future383925-Apr-10 17:06 
GeneralRe: Abstract Class Pin
Eddy Vluggen25-Apr-10 23:14
professionalEddy Vluggen25-Apr-10 23:14 
Member 4674360 wrote:
is my code right regarding the requirement?

You're going in the right direction, just keep working at it Smile | :)

For starters, I modified your code so that it compiles;
C#
int basket = 0;
Int32 rand = new Random().Next(0,4);
Int32 weight = new Random().Next(0,10000);

do
{
	switch (rand)
	{
		case 1:
			if (weight > 500 && weight < 2500)
				basket = basket + weight;
			break;
		case 2:
			if (weight > 500 && weight < 3000)
				basket = basket + weight;
			break;
		case 3:
			if (weight > 500 && weight < 4000)
				basket = basket + weight;
			break;
		case 4:
			if (weight > 500 && weight < 6000)
				basket = basket + weight;
			break;
	}
} while (basket >= 15000);

  • There's a break statement at the end of each case
  • Changed "rand" and "weight" to int, assuming you want to work with the numbers
  • Changed the order of the operators in the while loop; >= works, => doesn't compile (would be interpreted as a lambda-statement).


As your requirements go; I don't see a fish-class, nor a BinaryFormatter[^]. How about something like this;
C#
using System.Runtime.Serialization.Formatters.Binary;

[Serializable()]
public class MyFish
{
    public int Weight { get; set; }

    public MyFish()
    {
        Weight = new Random().Next(0,10000);
    }
}

I are Troll Suspicious | :suss:

GeneralRe: Abstract Class Pin
Calla26-Apr-10 1:07
Calla26-Apr-10 1:07 
GeneralRe: Abstract Class Pin
Eddy Vluggen26-Apr-10 1:20
professionalEddy Vluggen26-Apr-10 1:20 
GeneralRe: Abstract Class Pin
future383926-Apr-10 1:44
future383926-Apr-10 1:44 
QuestionHow to send & receive sms via gsm modem ? Pin
hdv21224-Apr-10 9:39
hdv21224-Apr-10 9:39 
AnswerRe: How to send & receive sms via gsm modem ? Pin
Md. Marufuzzaman24-Apr-10 20:35
professionalMd. Marufuzzaman24-Apr-10 20:35 
GeneralRe: How to send & receive sms via gsm modem ? Pin
hdv21225-Apr-10 10:34
hdv21225-Apr-10 10:34 
QuestionBest way for windows application with good performance , SQL & Oracle support? Pin
anand kumar m24-Apr-10 5:51
anand kumar m24-Apr-10 5:51 
AnswerRe: Best way for windows application with good performance , SQL & Oracle support? [modified] Pin
PIEBALDconsult24-Apr-10 6:42
mvePIEBALDconsult24-Apr-10 6:42 
Questionproblem with MSCHART spline graph! [modified] Pin
alibaba88s24-Apr-10 2:29
alibaba88s24-Apr-10 2:29 
AnswerRe: problem with MSCHART spline graph! Pin
Luc Pattyn24-Apr-10 2:57
sitebuilderLuc Pattyn24-Apr-10 2:57 
GeneralRe: problem with MSCHART spline graph! [modified] Pin
alibaba88s24-Apr-10 3:00
alibaba88s24-Apr-10 3:00 
GeneralRe: problem with MSCHART spline graph! Pin
Luc Pattyn24-Apr-10 3:08
sitebuilderLuc Pattyn24-Apr-10 3:08 
GeneralRe: problem with MSCHART spline graph! Pin
alibaba88s24-Apr-10 3:37
alibaba88s24-Apr-10 3:37 
GeneralRe: problem with MSCHART spline graph! Pin
alibaba88s24-Apr-10 3:41
alibaba88s24-Apr-10 3:41 
GeneralRe: problem with MSCHART spline graph! Pin
Luc Pattyn24-Apr-10 3:57
sitebuilderLuc Pattyn24-Apr-10 3:57 
GeneralRe: problem with MSCHART spline graph! [modified] Pin
alibaba88s24-Apr-10 4:06
alibaba88s24-Apr-10 4:06 
GeneralRe: problem with MSCHART spline graph! Pin
Luc Pattyn24-Apr-10 4:15
sitebuilderLuc Pattyn24-Apr-10 4:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.