CIS 3100 Structured Programming Intro

The cb object will store a deposit and check value

Info icon This preview shows pages 12–15. Sign up to view the full content.

View Full Document Right Arrow Icon
store the contents of the classes’ members. The cb object will store a deposit and check value  that when calculated via a class method called CurBal will return the checkbook balance.   Instantiating (instantiation) - Instantiating is very similar to declaring a variable. Instead of just a variable, instantiating declares an object and all of its members and puts it in memory. start   cb = CheckBook() cb.deposits = 100 print "Banking Summary" cb.deposits = (100 + cb.deposits) cb.checks = 100 cb.curBal() end class CheckBook: deposits equals 0 checks equals 0
Image of page 12

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
balance equals 0 curBal() balance = deposits - checks print "Deposits $" + deposits + " Checks $" + checks + " Balance = $" + balance return toString() print "Deposits $" + deposits + " Checks $" + checks + " Balance = $" + balance return End Class - Here we instantiate our class object so that operating system is notified that memory needs to  be allocated. We will refer to the class object by the name we assigned it cb. The naming of class  objects is similar to variables in that it is assigned by the programmer.   - In this statement, we are assigning a variable to the deposits member of the class object.   - In this statement, we are returning the current value stored in the deposits member, adding 100  to it and restoring it back into the deposits member.   - Here we are called the ~curBal method to execute a module.   - This marks the start of the class module.   - By standard, data variables are assigned at the beginning of the class file.   - Class methods are historically defined at the end of the class. Here we have two methods called  ~curBal and toString.  
Image of page 13
The program moves back and forth running logic from the program and then the class until all of  the program logic has been executed.     OOP TERMS, DEFINITIONS AND FUNDAMENTAL CONCEPTS       It is difficult to go right into modeling logic in OOP like we with did with structured programming.  OOP is not learned sequentially but instead more of a circular approach. In other words, you  learn a little about OOP and return to it and learn a little more. In this chapter, we will start with  and introduction and then return to the logic and programs again to learn a little more. First we  will review important terms, definitions and concepts associated with OOP. Some of these terms  and concepts have already been introduced but we will address them together in this section of  the chapter.             Related Subject: A light bulb event - OOP is always a complicated topic for programming students. I tell all my students the same thing. OOP is not a spectator sport. You must get your hands dirty by looking at OOP examples. It will certainly not come without some research and effort. Unlike learning to walk, OOP is not one of those instinctive things we will learn with time.
Image of page 14

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 15
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern