{"id":1340,"date":"2021-07-18T03:17:21","date_gmt":"2021-07-18T03:17:21","guid":{"rendered":"http:\/\/localhost\/wordpress\/?page_id=1340"},"modified":"2021-07-18T04:14:52","modified_gmt":"2021-07-18T04:14:52","slug":"lesson","status":"publish","type":"page","link":"http:\/\/localhost\/wordpress\/lesson\/","title":{"rendered":"Lesson"},"content":{"rendered":"\t\t
\n\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t
\n\t\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t
\n\t\t\t\t\t\t\t\t
\n\t\t\t\t
\n\t\t\t

Object Oriented Programming<\/h1>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t\t\t\t

Offers a sustainable way to write spaghetti code and lets you accrete programs as a series of patches<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t

\n\t\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t
\n\t\t\t\t\t\t\t\t
\n\t\t\t\t
\n\t\t\t

What is OOP?
<\/h2>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t\t\t\tOOP stands for Object Oriented Programming and is a programming model that relies on the concept of classes and objects. It is used to structure a software program into simple, reusable pieces of code blueprints usually called classes, which are used to create individual instances of objects. The examples of the languages that is used on OOP is Java.\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t
\n\t\t\t\t
\n\t\t\t


What the four basic OOP Programming?<\/h2>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t\t\t\t


1. Abstraction.<\/strong><\/p>

Abstraction means using simple things to represent complexity.
Example: A car in itself is a well-defined object, which is composed of several other smaller objects like a gearing system, steering mechanism, engine, which are again have their own subsystems. But for humans car is a one single object, which can be managed by the help of its subsystems, even if their inner details are unknown.

2. Encapsulation.<\/strong><\/p>

This is the practice of keeping fields within a class private, then providing access to them via public methods.
An example of encapsulation is the class of java.util.Hashtable. User only knows that he can store data in the form of key\/value pair in a Hashtable and that he can retrieve that data in the various ways. But the actual implementation like, how and where this data is actually stored, is hidden from the user. User can simply use Hashtable wherever he wants to store Key\/Value pairs without bothering about its implementation.

3. Inheritance.<\/strong><\/p>

It lets programmers create new classes that share some of the attributes of existing classes. This lets us build on previous work without reinventing the wheel. For example, you could create the class Car that specifies wheels = 4 and a subclass Sedan that includes the attribute doors = 4. The flow of inheritance relationships often reflects the logical relationship similar to squares and rectangles; in this case, all sedans are cars, but not all cars are sedans.

4. Polymorphism.<\/strong><\/p>

This concept lets programmers use the same word to mean different things in different contexts. For example, the human body has different organs. Every organ has a different function to perform; the heart is responsible for blood flow, lungs for breathing, brain for cognitive activity and kidneys for excretion. So we have a standard method function that performs differently depending upon the organ of the body.<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t

\n\t\t\t\t
\n\t\t\t


Object-Oriented Requirements Models<\/h2>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t\t\t\t
\n\nThe models requires in OOP are class model, state model, and interaction model. The class model shows all the classes inside the system. The state model, defines the actions inside of a state diagram. The interaction model is used to show various interactions between objects, one of example of this is Sequence Diagram. In object-oriented requirements analysis, you should model real-world entities using object classes. You may create different types of object model, showing how object classes are related to each other, how objects are aggregated to form other objects, how objects interact with other objects and so on.\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t
\n\t\t\t\t
\n\t\t\t


\nTasks\n
<\/h2>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t\t\t\tA. VENDING MACHINE<\/strong>\n
\nYou need to design a Vending Machine which\n
    \n \t
  1. \u00a0Accepts coins of 1,5,10,25 Cents i.e. penny, nickel, dime, and quarter.<\/li>\n \t
  2. \u00a0Allow user to select products Coke(25), Pepsi(35), Soda(45)<\/li>\n \t
  3. \u00a0Allow user to take refund by canceling the request.<\/li>\n \t
  4. \u00a0Return the selected product and remaining change if any<\/li>\n \t
  5. \u00a0Allow reset operation for vending machine supplier.<\/li>\n<\/ol>\nThere are 10 classes to be included:\n

    \n\n\n\n\n\n\n\n\n\n\n\n\n\n
    Class Name<\/th>\nDescription<\/th>\n<\/tr>\n
    VendingMachine<\/td>\nIt defines the public API of a vending machine, usually, all high-level functionality should go in this class<\/td>\n<\/tr>\n
    VendingMachineImpl<\/td>\nA sample implementation of Vending Machine<\/td>\n<\/tr>\n
    VendingMachineFactory<\/td>\nA Factory class to create different kinds of Vending Machine<\/td>\n<\/tr>\n
    Item<\/td>\nJava Enum to represent Item served by Vending Machine<\/td>\n<\/tr>\n
    Inventory<\/td>\nJava class to represent an Inventory, used for creating the case and item inventory inside Vending Machine<\/td>\n<\/tr>\n
    Coin<\/td>\nAnother Java Enum to represent Coins supported by Vending Machine<\/td>\n<\/tr>\n
    Bucket<\/td>\nA parameterized class to hold two objects. It’s kind of Pair class.<\/td>\n<\/tr>\n
    NotFullPaidException<\/td>\nAn Exception is thrown by Vending Machine when a user tries to collect an item, without paying the full amount.<\/td>\n<\/tr>\n
    NotSufficientChangeException<\/td>\nVending Machine throws this exception to indicate that it doesn’t have sufficient change to complete this request.<\/td>\n<\/tr>\n
    SoldOutException<\/td>\nVending Machine throws this exception if the user requests a product that is sold out.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n\n
    \nB. SONGSALES<\/strong>\n
    \nImagine that you and your band have just recorded a song, and you want to permit fans to purchase and download the song over the Internet. Your manager receives a commission equal to 12% of the total sales revenue for your song. and the Internet site that list your song receives a 3% commission.\n
    \nDesign a Java Program that ask for the title of the song, the purchase price of the song (in peso and cents), and the number of copies of the song that have been sold. Calculate the total revenue generated by your song, the commission received by your manager, and the commission received by the Internet site.\n\n
    \n
    \nC. SONGSALES_GUI<\/strong>\n
    \nRedesign the program on SongSales, which you created in Task C. Use a dialog box to ask the user for the title of the song, the purchase price of the song (in peso and cents), and the number of copies of the song that have been sold. Calculate the total revenue generated by your song, the commission received by your manager, and the commission received by the Internet site.\n\n
    \n
    \nD. LEAP YEAR OR NOT?<\/strong>\n
    \nWrite a program that replies either Leap Year or Not a Leap Year, given a year. It is a leap year if the year is divisible by 4 but not by 100 (for example, 1796 is a leap year because it is divisible by 4 but not by 100). A year that is divisible by both 4 and 100 is a leap year if it is also divisible by 400 (for example, 2000 is a leap year, but 1800 is not).\n\n

    \n\nE.<\/strong> EMPLOYEES AT MYJAVA LO-FAT BURGER<\/strong>\n
    \nEmployees at MyJava Lo-Fat Burgers earn the basic hourly wage of $7.25. They will receive time-and-a-half of their basic rate for overtime hours. In addition, they will receive a commission on the sales they generate while tending the counter. The commission is based on the following formula\n

    \n\"\"\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t
    \n\t\t\t\t
    \n\t\t\t


    \nSolutions<\/h2>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t
    \n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t
    \n\t\t\t\t\t\t\t\t
    \n\t\t\t\t
    \n\t\t\t\t\t\t\t\tA. VENDING MACHINE<\/strong>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t
    \n\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t
    <\/div>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t
    \n\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t<\/i>\t\t\t<\/span>\n\t\t\t\t\t\tDownload Source Code<\/span>\n\t\t<\/span>\n\t\t\t\t\t<\/a>\n\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t
    \n\t\t\t
    \n\t\t\t\t\t\t\t\t
    \n\t\t\t\t
    \n\t\t\t\t\t\t\t\tB. SONGSALES<\/strong>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t
    \n\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t
    <\/div>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t
    \n\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t<\/i>\t\t\t<\/span>\n\t\t\t\t\t\tDownload Source Code<\/span>\n\t\t<\/span>\n\t\t\t\t\t<\/a>\n\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t
    \n\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t
    <\/div>\n\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t
    \n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t
    \n\t\t\t\t\t\t\t\t
    \n\t\t\t\t
    \n\t\t\t\t\t\t\t\t\nC. SONGSALES_GUI<\/strong>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t
    \n\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t
    <\/div>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t
    \n\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t<\/i>\t\t\t<\/span>\n\t\t\t\t\t\tDownload Source Code<\/span>\n\t\t<\/span>\n\t\t\t\t\t<\/a>\n\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t
    \n\t\t\t
    \n\t\t\t\t\t\t\t\t
    \n\t\t\t\t
    \n\t\t\t\t\t\t\t\t\nD. LEAP YEAR OR NOT?\n<\/strong>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t
    \n\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t
    <\/div>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t
    \n\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t<\/i>\t\t\t<\/span>\n\t\t\t\t\t\tDownload Source Code<\/span>\n\t\t<\/span>\n\t\t\t\t\t<\/a>\n\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t
    \n\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t
    <\/div>\n\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t
    \n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t
    \n\t\t\t\t\t\t\t\t
    \n\t\t\t\t
    \n\t\t\t\t\t\t\t\t\nE. EMPLOYEES AT MYJAVA LO-FAT BURGER<\/strong>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t
    \n\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t
    <\/div>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t
    \n\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t<\/i>\t\t\t<\/span>\n\t\t\t\t\t\tDownload Source Code<\/span>\n\t\t<\/span>\n\t\t\t\t\t<\/a>\n\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t
    \n\t\t\t
    \n\t\t\t\t\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"

    Object Oriented Programming Offers a sustainable way to write spaghetti code and lets you accrete programs as a series of patches What is OOP? OOP stands for Object Oriented Programming and is a programming model that relies on the concept of classes and objects. It is used to structure a software program into simple, reusable …<\/p>\n

    Lesson<\/span> Read More »<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":[],"_links":{"self":[{"href":"http:\/\/localhost\/wordpress\/wp-json\/wp\/v2\/pages\/1340"}],"collection":[{"href":"http:\/\/localhost\/wordpress\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"http:\/\/localhost\/wordpress\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"http:\/\/localhost\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/localhost\/wordpress\/wp-json\/wp\/v2\/comments?post=1340"}],"version-history":[{"count":6,"href":"http:\/\/localhost\/wordpress\/wp-json\/wp\/v2\/pages\/1340\/revisions"}],"predecessor-version":[{"id":1409,"href":"http:\/\/localhost\/wordpress\/wp-json\/wp\/v2\/pages\/1340\/revisions\/1409"}],"wp:attachment":[{"href":"http:\/\/localhost\/wordpress\/wp-json\/wp\/v2\/media?parent=1340"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}