Object Oriented Programming
You are to build a windows forms application project. This project deals with keeping track of the different budgets a company allocates to each department. As well as keeping track of all the expenses make of a given budget.
You are going to build 3 classes.
1. Base class Budget
2. Child class HomeBudget
3. Child class BusinessBudget
4. in Form1 you would need a listview and a listbox. The listview is used to display all the budgets
5. the listbox is to display all the expenses of the selected budget from the listview
Building the project
1. Create the project. Set up the Form1_Design to have a Listview, a listbox
2. Define a class Budget. This class should have
a. Private fields: _balance (this is the amount of money available or left in the budget
to be spent)
_budgetCode (every budget has an id code by which to access it.
Could be a string or an int.
_expenseList (List<decimal>) this list will contains all the
Transactions that took place. Every time an expenditure occurs it is
added to this list and the balance is deducted the expenditure made
b. Constructor and properties for all the fields
c. Methods:
public bool MakePurchase(decimal expenseAmount){}
This method is to get the amount of this expense, decide whether the expense will go through or not, then to reduce the current budget balance by this amount,
and to add this expense amount to the _expenseList.
Return true or false according to the decision made.
public void UpdateBudgetBalance(decimal amount){}
This method is to update the balance by either adding the amount to it or subtracting the amount from it.
The amount is not an expense,it is the amount by which to adjust the budget balance.
you decide on what changes you need to make to this method so that you can use it for adding and subtracting the amount to/from balance
public string GetBudgetInfo(){.}
this method is return a string that contains all the information about this budget.
3. Define a class BusinessBudget that inherits (polymorphically) from Budget.
a. This class should define an extra private field _department (String). This is the name of the department this businessBudget is allocated to.
b. Complete the necessary code in this class to make it a functional child
4. Define a class HomeBudget that also inherits (polymorphically) from Budget
a. This class should define an extra private field also _category (String) this describe where this budget is used for such as: Food, Clothing, Entertainment, etc
b. Complete the necessary code in this class to make it a functional child
5. In Form1, Create a single List to hold all the budgets (Business and Home)
Define a method PreloadBudgetList that populate the budgetList with at least 5 budgets of each type.
Define also a method Display that takes a single parameter, which is a List of budgets.
This method is to display all the budgets in the listview. The listview should display:
Type of budget, budget code, budget balance
You could find out what type of budget it is and display whether the Department for the business budget, or the Category for the home budget
6. Add code to the listview SelectedIndexChanged (when you select an item from the listview), display all the expenses of the selected budget in the listbox
7. Provide a button remove expense to remove the selected expense (in the listbox) from the selected budget (in the listview). Note that it is not enough to remove from the listbox, it must be removed from the selected budget itself. Redisplay the budgets to see that the expense is gone from the budget.
8. Provide a button (Add new expense), a label (new expense) and a textbox (txtNewExpense) to add this new expense to the selected budget. Redisplay to see the effect. (make the necessary addition to the Budget class to make this operation possible.)