freeCodeCamp/CurriculumExpansion

Budget App (Certification Project)

Closed this issue ยท 17 comments

I have few notes for the README file.

Complete the Category class in budget.py. It should be able to instantiate objects based on different budget categories.

I had a hard time visualizing the project until I reached the example of the output. Moving the example at the top might be excessive, but perhaps we could add a few categories to further explain the purpose of the Category class. Picking from the testing suite, we could add the line based on different budget categories like Food, Clothing, Entertainment.

When objects are created, they are passed in the name of the category.

I believe the line should be with the name of the category.

The class should have an instance variable called ledger that is an array. It should contain the following methods:

This might be because I'm still new to Python, but I briefly considered that it was the ledger that was supposed to contain the methods which followed. Perhaps we should reiterate the subject of the sentence: The class should also contain.

Also and regarding the ledger "array": throughout the assignment we refer to arrays, but in the documentation of the Python language the data structures represented by square brackets are labeled as lists. Perhaps we update the text to match.

A get_balance array that returns the current balance of the budget category based on the deposits and withdrawals that have occurred.

I believe the sentence should describe the get_balance method

The method should add a withdrawal with the amount and the description "Transfer to [Other Budget Category]". The method should then add a deposit to the other budget category with the amount and the description "Transfer to [Current Budget Category]".

The second statement should be Transfer from [Current Budget Category].

The labels "Other" and "Current" are also a tad misleading, and perhaps could be renamed to "Receiving" and "Sending", or "Destination" and "Source".

The amount should be left aligned, contain two decimal places, and display a maximum of 7 characters

I believe the amount is meant to be right aligned.

Under the Development heading, the text refers to another project: Polygon Area Calculator

Thank you for your reviews @borntofrappe and @notingGone. Your suggestions will really help us clean up the text before we launch this project.

@borntofrappe Thanks for catching all those mistakes. I have to admit I was embarrassed that I didn't catch some of those previously. :)
@notingGone Your right! Thanks.

The class should have an instance variable called ledger that is an list

I think this is a typo, it should be a list instead of an list.


When the budget object is printed, I found out the test suite doesn't actually check the title in the title line, but instead it checks once for *************Food*************.

This means if we hardcoded the title line as *************Food************* we would still pass the test, even though the title line should change based on the title.

@adamdune Fixed the typo, thanks. I updated the test so the title is not hard-coded. However, there is only so much we can do to prevent people from looking at the tests and then passing the tests in ways that we didn't intend.

Rnso commented

test_to_string fails with the error
AttributeError: 'Category' object has no attribute 'name'

I think it is because i declared category object with an attribute 'category' instead of 'name'. I feel the name of the attribute should not be restricted to 'name' unless otherwise mention so in the description of the assignment.

@Rnso, that's a good point. It might be difficult to mention that in the description, so we might be able to include it in the seed code. For example, we could have

class Category:
  def __init__(self, name):

Instead of the current

class Category:

Alternatively, we could change the test so it expects *************Food************* since we know that's what the category should be.

Rnso commented

@scissorsneedfoodtoo both options are okay. I would prefer the first one though (i.e, include it in the seed code).

Little ticket printing app.
Here's the url to my repo budget app.

Rnso commented

@jdelarubia looked into your solution.
I am sorry actually the error in my case was because of the name of property (self.category = category) and not the name of attribute (def init(self, category)).

In that case, the second option is more apt I suppose.

@Rnso, no worries. Thank you for bringing this to our attention. This is still something we should investigate since we want the tests to be as flexible as possible. Ideally you would be able to name the attributes whatever you want.

@beaucarnes, what do you think about changing the expected string in test_to_string? I'm thinking it could check for *************Food************* rather than *************{self.food.name}*************.

I updated the test to check for *************Food*************.

Hi there guys! I'm here to upload my solution to this problem.

Budget App

Oh, by the way, I found a little error in the redaction of the Readme in the withdraw section.

It says:

A transfer method that accepts an amount and another budget category as arguments. The method should add a withdrawal with the amount and the description "Transfer from [Source Budget Category]". The method should then add a deposit to the other budget category with the amount and the description "Transfer to [Destination Budget Category]". If there are not enough funds, nothing should be added to either ledgers. This method should return True if the transfer took place, and False otherwise.

But it should say:
A transfer method that accepts an amount and another budget category as arguments. The method should add a withdrawal with the amount and the description "Transfer to [Destination Budget Category]". The method should then add a deposit to the other budget category with the amount and the description "Transfer from [Source Budget Category]". If there are not enough funds, nothing should be added to either ledgers. This method should return True if the transfer took place, and False otherwise.

Hi @robertue1, thanks for your feedback. Also, great catch with the description in the Readme. I'll go in and fix that now.

Had fun completing this project and got more confident in oop.
Personally I felt making chart tough.
Link : https://repl.it/@ManshulArora/budget-app

I completed the new version of the project. and have a few notes on the starter project.

main.py

This is trivial, but the class and the function are imported with a different syntax.

import budget
from budget import create_spend_chart

Perhaps it's better to use a single technique for both:

  • import budget

    import budget
    

    The category and function are then called with budget.Category and budget.create_spend_chart

  • alternatively, import the necessary values

    from budget import Category, create_spend_chart

    The two are then called without the need to specify the module

README.md

For the content, I've but a minor suggestion regarding the deposit method, where the keyword dictionary might be better suited than object

The method should append an object a dictionary to the ledger list in the form of {"amount": amount, "description": description}.

For the overall structure, splitting the document in two sections might help understanding the assignment better:

  • Category

  • create_spend_chart

Similarly to @manshul1807, I had a hard time with the function, and I've updated the README to try and explain it more thoroughly.


create_spend_chart

The function takes as argument a list of categories, and returns a string describing a bar chart. The chart should show how much of the total expenditure can be explained by each category. Calculate the percentage using only withdrawals, and not with deposits.

The function should display:

  • a title that says "Percentage spent by category"
  • on the left side the labels describing the percentages in the [0, 100] range
  • o characters for the individual bars. The height of each bar should be rounded down to the nearest 10
  • a horizontal line made of - dash characters. The line should begin one space after the pipe character | separating the percentages, and continue one space past the final category
  • the name of each category, displayed vertically below the horizontal line

Each category should occupy three spaces.

Look at the example output below very closely and make sure the spacing of the output matches the example exactly.

Percentage spent by category
100|
 90|
 80|
 70|
 60| o
 50| o
 40| o
 30| o
 20| o  o
 10| o  o  o
  0| o  o  o
    ----------
     F  C  A
     o  l  u
     o  o  t
     d  t  o
        h
        i
        n
        g

The example is based on the following withdrawals

Category Withdrawals
Food 76.04
Clothing 25.5
Auto 15

Which explain the percentages of roughly 65%, 22% and 13%, rounded down to 60, 20 and 10 respectively.


Let me know if that's clear enough. I've updated the README in my forked project for reference:

https://repl.it/@borntofrappe/fcc-budget-app#README.md