0% found this document useful (0 votes)
6 views14 pages

Java Class Development Tutorial

Uploaded by

Deceived
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views14 pages

Java Class Development Tutorial

Uploaded by

Deceived
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

TUTORIAL 02

BUSI 2402 APPLICATION DEVELOPMENT


AGENDA

• Assignment 01

• Classes

• Mutators & Accessors (Setters & Getters)

• Constructors
ASSIGNMENT 01

• Pseudocode
• Simple Java Output
• Graphical Java Output
• Class documentation using UML Notation
CLASSES

• Classes are a combination of Attributes (Variables) & Behaviours (Methods) that are used to
provide functionality to a system.
• Can either represent something tangible in a business (e.g. Customer, Product) or something
system-specific (e.g. classes to access databases)
• Classes can exist on their own or in a relationship with other classes (e.g. Inheritance,
Aggregation)
• We can use UML Class Diagrams to describe classes within a system.
CONSTRUCTORS
• A “Class” is the blueprint for the creation of “Objects” that actually perform a function in your
application.
• Example: Customer
CONSTRUCTORS

• To create our objects, we need a Constructor method.

• Every class has a “default” constructor that creates an object, based on a class, but leaves all
attributes empty (null).

• We could use setters & getters to then populate our empty object, but another alternative is
to define our own constructors.

• We first start with overriding the default constructor with our own basic version, then we can
write more complex ones based on our needs.
THE DEFAULT CONSTRUCTOR

Here is the sample class with attributes and


the Default constructor.

The constructor initializes each of the


attributes to an “empty” value that will
require a Setter method to update.
SETTERS & GETTERS

• Methods used to modify and return class


attributes
• Added to classes for a variety of purposes:
• Validating Inputs (e.g. Making sure “First
Name” is not set to “12345”)
• Validating Access Permission (e.g. “Does this
user have permission to view this data?”)
CLASS SETTERS & GETTERS
OVERLOADING CONSTRUCTORS

• In the prior example, we had to (1) Create an Object of the Class (John) and the (2) Set each
attribute of the Object to its appropriate value.
• We can do this in one step by using an Overloaded Constructor
CLASS WITH TWO CONSTRUCTORS
THE FULL CLASS
GOING FORWARD

• Assignment 01 is due October 5th


• Make sure you get Eclipse and a UML tool (Violet, [Link]) working
REFERENCES
HANSSEN, D. (2021). TUTORIAL 02. LECTURE.

You might also like