Phil Tayco Slide version 1.0 Created Nov. 26, 2017

Slides:



Advertisements
Similar presentations
CHAPTER 7 ACCOUNTING INFORMATION SYSTEMS
Advertisements

Week 8 Recap CSE 115 Spring Composite Revisited Once we create a composite object, it can itself refer to composites. Once we create a composite.
Abstract Classes and Interfaces The objectives of this chapter are: To explore the concept of abstract classes To understand interfaces To understand the.
Intro to OOP with Java, C. Thomas Wu Inheritance and Polymorphism
Inheritance Java permits you to use your user defined classes to create programs using inheritance.
Java™ How to Program, 9/e Presented by: Dr. José M. Reyes Álamo © Copyright by Pearson Education, Inc. All Rights Reserved.
George Blank University Lecturer. CS 602 Java and the Web Object Oriented Software Development Using Java Chapter 4.
HST 952 Computing for Biomedical Scientists Lecture 2.
CSE 331 Software Design & Implementation Hal Perkins Autumn 2012 Java Classes, Interfaces, and Types 1.
CET203 SOFTWARE DEVELOPMENT Session 3B Interfaces.
CISC6795: Spring Object-Oriented Programming: Polymorphism.
Recap (önemli noktaları yinelemek) from last week Paradigm Kay’s Description Intro to Objects Messages / Interconnections Information Hiding Classes Inheritance.
1 Java Inheritance. 2 Inheritance On the surface, inheritance is a code re-use issue. –we can extend code that is already written in a manageable manner.
Chapter 9 Accounting for Merchandising Operations.
Features of Object Oriented Programming Lec.4. ABSTRACTION AND ENCAPSULATION Computer programs can be very complex, perhaps the most complicated artifact.
An Introduction to Java Chapter 11 Object-Oriented Application Development: Part I.
Java™ How to Program, 9/e Presented by: Dr. José M. Reyes Álamo © Copyright by Pearson Education, Inc. All Rights Reserved.
Chapter 2 Introducing Interfaces Summary prepared by Kirk Scott.
Object Oriented Software Development
 All calls to method toString and earnings are resolved at execution time, based on the type of the object to which currentEmployee refers.  Known as.
Java Programming Dr. Randy Kaplan. Abstract Classes and Methods.
Programming with Java © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 1 McGraw-Hill/Irwin Chapter 5 Creating Classes.
CS 61B Data Structures and Programming Methodology July 2, 2008 David Sun.
Class Builder Tutorial Presented By- Amit Singh & Sylendra Prasad.
Interfaces F What is an Interface? F Creating an Interface F Implementing an Interface F What is Marker Interface?
Abstract Classes and Interfaces Week 17.  Computer simulations  Abstract methods  Abstract classes  Interfaces  Multiple inheritance Abstract Classes.
Java Programming, Second Edition Chapter Twelve Advanced Inheritance Concepts.
CET203 SOFTWARE DEVELOPMENT Session 2A Inheritance (programming in C#)
Lecture 2: Review of Object Orientation. © Lethbridge/La ganière 2005 Chapter 2: Review of Object Orientation What is Object Orientation? Procedural.
1 Chapter 8 Class Inheritance and Interfaces F Superclasses and Subclasses  Keywords: super F Overriding methods  The Object Class  Modifiers: protected,
Inheritance.
ACCOUNTING DEPARTMENT WORKFLOW
TRANSACTION PROCESSING SYSTEM (TPS)
Phil Tayco Slide version 1.0 Created Sep 18, 2017
Inheritance and Polymorphism
EKT 472: Object Oriented Programming
About the Presentations
Functions Separate Compilation
Phil Tayco Slide version 1.0 Created Nov 6, 2017
Lecture 9-2: Interacting with the Superclass (super);
Phil Tayco Slide version 1.1 Created Oct 30, 2017
abstract classes and casting objects
Section 11.1 Class Variables and Methods
Phil Tayco Slide version 1.0 Created Oct 2, 2017
Local Government Corporation
Object-Oriented Programming: Polymorphism
Comp 249 Programming Methodology
The Object-Oriented Thought Process Chapter 05
Chapter 9 Object-Oriented Programming: Inheritance
NextGen Trustee General Ledger Accounting
Chapter 6 Methods: A Deeper Look
Java Programming Language
Polymorphism Phil Tayco San Jose City College Slide version 1.1
Java Programming Arrays
Advanced Java Programming
Java Programming Function Introduction
OO Design with Inheritance
Product Training Jobs Where “Lean” principles are considered common sense and are implemented with a passion! ©2008 TTW.
Spring 2018 Final Project Phil Tayco San Jose City College
In Class Exercises Phil Tayco Slide version 1.1 San Jose City College
Inheritance Phil Tayco San Jose City College Slide version 1.2
Chapter 14 Abstract Classes and Interfaces
Interfaces.
Abstract Classes and Interfaces
Chapter 8 Class Inheritance and Interfaces
Final and Abstract Classes
Building Java Programs
Java Programming Function Introduction
Abstract Classes and Interfaces
Database management systems
Presentation transcript:

Phil Tayco Slide version 1.0 Created Nov. 26, 2017 More Exercises Phil Tayco Slide version 1.0 Created Nov. 26, 2017

More Practice Problem statement: Design a class infrastructure that manages payroll for a department as follows: All departments have at most 10 employees Employees are either paid hourly or weekly All employees have a numeric id and a name Hourly employees have an hourly pay rate Salary employees have a weekly pay rate Demonstrate this program by showing different employees added to the department and reporting the following: Total monthly pay for all department employees Who is paid the highest and lowest

More Practice A prime benefit of OO design is the infrastructure giving you power to handle change New problem requirements: Years of service for every employee Create a commission based employee who gets a percentage of total sales for pay Given multiple departments, how do we find out which department gets paid more? How do we find out which employee in all departments is the highest paid?

Observations To be discussed

Static and Final Classes may contain properties and methods that may not require an object to be created for it to be used public double calculateArea() { return Math.PI * radius * radius; } “Math.PI” is a property in the Math class and is static When a method or property is public and static, it means you can use it without having the need to create an object In this example, we don’t have to create a Math object to use PI. We are simply accessing the definition of it made public to us through the Math class This makes sense because there really isn’t a need to use memory for concepts that are fundamentally fixed (their definition is “static”)

Static and Final Notice PI is also in all caps. This is the standard Java notation to define a constant Constants in classes are often static and made public to show certain fixed information associated with the concept of the class In our example, we can design that all departments have a fixed maximum number of employees: public class Department { public final static MAX_EMPLOYEES = 10; } This can be used by code in the Department class as well as outside it as needed Constants help make code readable and when used properly, can be adjusted to maximum code change efficiency (i.e. changing the max in a department to 50)

Interfaces Java also supports a special type of abstract class called an interface Interfaces are restricted to defining only abstract methods and can be thought of as a form of a superclass public interface Payable { public double calculateMonthlyPay(); } Any subclass can inherit from this through coding that the class will “implement” the interface: public class Employee implements Payable This gets the same treatment as a subclass inheriting from an abstract class like “Payable” in that it must now define “calculateMonthlyPay” (or else Employee must be abstract)

Interfaces Interfaces only define method signatures and is a form of an abstract class There are two differences with abstract classes and interfaces: Abstract classes can still contain properties and methods that can be inherited. Interfaces only define abstract methods Subclasses in Java can only “extends” one superclass. Subclasses that “implements” interfaces can implement multiple interfaces More examples can and should be practiced from these concepts

Another Example Design and implement a prototype that manages sales of computer products for employees Sales employees are identified by a name and number A record of up to 1000 sales transactions is maintained for each sales employee Sales transactions are either standard or bulk Standard transactions are identified by a number, a product sold and the quantity sold for that product Bulk transactions are also identified by a number and up to 100 products for the sale Bulk transactions also can have a discount amount for the sale

Another Example Computer products are either hardware or software Hardware products are identified by name, price and manufacturing company Software products are identified by name, price, developer company and software version number The management system allows for creation of up 5 sales employees, recording sales and reporting employee performance When a sale is recorded, the sales employee is identified for the sale and the type of transaction Employee performance shows each sales transactions and the total revenue of them all

Observations The main program is complex and is separate from the class design allowing it to be developed in different ways (command line, windows or web application) Composition and Polymorphism: Sales Employee containing an array of Sales Transactions and Transaction types containing use of Products Inheritance: Software and Hardware products inheriting basic information from Product. Standard and Bulk transactions inherit from Sales Transaction Abstract classes: Sales Transaction is abstract requiring calculating sale in the subclasses

Programming Project Create a task management planner program Tasks have a description and are either time constrained or either dependent or independent of other tasks Time constrained tasks have a start and end date and time. Time constrained tasks cannot overlap (If one time constrained task is for 2pm-4pm on a given day, a second time constrained task such as from 3pm-5pm on the same day would not be allowed) Once the end date and time have passed for a time constrained task, the task is considered to be complete Time constrained tasks can also be marked as complete before the end date and time is reached

Programming Project Create a task management planner program Dependent and independent tasks are not time constrained and only have a start date (no start time needed) Independent tasks are considered started once the start date is reached Dependent tasks have another task (which can be dependent or independent in itself) that it depends on to be completed as well as its own start date Dependent tasks can only start if the start date is reached and the task it is dependent on is considered complete Once any of these tasks are started, they are considered finished when the task is manually marked as complete

Programming Project To simulate and test the task management planner, create a calendar where you can manually change the current date and time As the current date and time is updated in the calendar, all task statuses are updated as needed The main planning program shall allow for the following features: Create a new task Change the current date and time Mark a task as complete Report tasks Features 1-3 should obtain the necessary information to perform the function with appropriate error handling Reporting tasks should at least include listing all tasks, which ones have not started, started and complete

Programming Project Data for tasks should be persistent and should be saved/loaded to a text file or database The requirements list is somewhat open-ended by design. You are free to design your classes and implement your main program as you like. Any questions should be asked sooner rather than later Programming requirements are to demonstrate all concepts discussed in class: Class design, use of composition, inheritance, polymorphism, error handling and data saving Program can and encouraged to be developed in teams of at most, 2 people. Single individual development is acceptable, but requirements list does not change if you’re doing it by yourself Program is due for demonstration on the last day of class