Suppose that you are developing a class, Account, from which a customer can
withdraw money. The Account class needs to keep track of the number of
withdrawals that have occurred in each customer’s account. The partial
specification for Account class is given below. You are required to complete the
code for the Account and Tester classes. Comment all of your code and make sure
to put your name as a comment at the top of your program.

class Account
{
//variables
accountNumber;
accountBalance;
static numberOfWithdrawal;
Account(int account, int amount)
{
//constructor class
}
Withdraw(int account, int amount)
{
//withdraw the amount from the balance
}
DisplayAccountBalace()
{
//display the current account balance to console
}
Static DisplayNumberOfWithdrawal()
{
//display the number of withdrawals to console
}
}
class Tester
{
Main()
{
/*create three Account objects and withdraw money twice from
each account. Then display the account number and current
balance for each account to the console. */
/*display the total number of withdrawals from the three accounts
to console.*/
}

This is what i have so far. I had to miss class one day and it screwed me. Please Help!

Recommended Answers

All 18 Replies

That is what you have so far? It really looks like you are quoting directly off an assignment.

None of your functions or variables have been typed. That would be a good start.

each withdraw increment the numberOfWithdrawal

That is what I typed. I couldn't go any further because I really don't understand objects. If someone could explain it, or give me an example within the project to get me started, I would greatly appreciate it.

imagine a cookie cutter. That is a class. Now a cookie is an object of the class that is cookie cutter!

i.e. a cookie cutter can be used >1 time to make numerous objects

First Withdraw shoud be public and some methods too

public Withdraw(int account, int amount)
{
Account.numberOfWithdrawal++;
..... // rest of code
..... // rest of code
}

I see you hardly need to read in OOP before programming with C#, you won't do true projects with C# before fully understanding the concept of OOP.

i.e. a cookie cutter can be used >1 time to make numerous objects

ok that sorta makes sense

but i am still lost....

I am the c# class right now, and i can't learn in here cuz my teacher is from china and i can't understand him so i have to teach myself(or get help here)

That is what I typed. I couldn't go any further because I really don't understand objects. If someone could explain it, or give me an example within the project to get me started, I would greatly appreciate it.

That's just it though. NOTHING is typed! Let's take a step back and look at the code.

Assume it's C++, as from looking at your past postings that is another language you know. If you wrote all those functions and variables in C++, would they compile? No. Why? Because the compiler has no idea what any of them are typed (this isn't PHP, the compiler MUST know what each variable type is and must know if the functions are returning a variable or not).

I say it looks like you copied code because you have the function parameters typed (which means you somehow knew how to type those) and you even know about the concept of 'static' variables and function, yet you didn't type the basic variables they teach you almost in day one of any programming course?


So again, before you even try to deal with the higher level concept of Objects, look at the code and create all the types for the functions and variables. The typing of these is done the same way whether or not you use objects in the program. That's why you should just ignore the objects part first and deal with the basics that you should understand. The ONLY 'function' in all of that code that does not get typed is the Constructor for Class Account.

so i can type all the functions within the program without objects?

I didn't know that.

so I can go on an type the function that records the number of withdrawals before even looking at objects?

would anyone recommend C# for Dummies?

I will get flamed for this but yes I would lol

everyone has to learn somewhere I used C# for dummies and found it helpful - its easy to follow and has good examples.The stuff in there is obviously not that advanced but like I said, everyone has to start somewhere

I recommend Inside C# and How to program

but all in all MSDN is the best for ever, I didn't learn C# from a book, everything I look at MSDN and some methods documentation and some trying...

or there is SAMS teach yourself c# in 21 days thats quite good

guys you have been great help....i am gonna try and write that program now, and i'll post it later, and get your feedback

sure thing good luck

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.