Hey everyone,
I'm new to these forums, and I'm also just learning C# I'm trying to learn the language. I'm just trying to learn the language by working on projects, but I'm running into some problems. I'm new here, so please don't rake me through the coals :(
I want to make a bank account that creates random account numbers, using object oriented methods.
I'm trying to add randomly generated account numbers to Account objects, but I'm running into some problems, and I haven't been able to find any solutions online. I know there's tons of resources out there, but I'm still having issues trying to piece everything together.
1) I want to first add a private static object Random to my class, which I named "Account" - separate class from the main program
2) Then I tried to create a random number generating function to my "Account" class, which you can see is named "random3digInt". It should return a value, and I don't really know if it needs parameters.
3) In the constructor, I want to call the random3digInt function so that random numbers can be generated and assigned to the account number value - I'm guessing whatever I have in the parameter list is wrong
class Account
{
const double DEFAULT_INTEREST = 2.5;
private int accountNo;
private double balance;
private double interestRate;
private string message;
private Random rg;
public void random3digitInt()
{
int AccountNo;
AccountNo = rg.Next(100, 999);
return;
}
public Account(int acctNo, double bal, double ir)
{
acctNo= Randorandom3digitInt();
message = "";
if (bal >= 0)
{
balance = bal;
}
else
{
... didn't copy all the code
In my main program, I have this: (and I know it's all very wrong)
static void Main(string[] args)
{
Account acct = new Account(acctNo,100,2.5);
acct.display();
int choice;
double bal, r, amt;
int y;
double fut;
Thanks!