Share
Explore

f24 Java Assignment 1

image.png
megaphone

What you are to do for this Assignment:

Part 1: Create a Class Hierarchy for the College Enrollment System
Part 2: Deliver a complete application to make the college enrollment system work.

What are the generalizing principles of HOW we:
Create Classes, and
Plug them together
to construct a well-behaved Software System ?

megaphone

What is the purpose of writing a computer program?

a. Games for fun, or learning (business simulations)
b. Numerical Analysis.
c. (THIS IS WHAT YOUR JOB WILL BE:) Writing software which “delivers”/”makes it happen” a business domain. SUD System under design/discussion.

Business Domain = The set of a the rules/processes/instruction steps which run the business.
Business process ←> Business Object (interchangable terms).

A business object is box into which I can put a business process.
That box is a little engine, like a radio controlled car, which runs the process.

A business process has 3 things:
NAME of business process
Data : needed to run the business process
Actions (doing stuff) needs to do the process.

A Java Object has 3 things:

Unique ID ( when we write a Java Object to run a Business Process name = name)
Data Fields. ( a business process has data)
Methods. ( a business process has action steps to deliver).

Part A of Assignment 1:

Create a Class Hierarchy for a Java Program which Delivers a business domain.
A class hierarch is: a simplified Java Program which shows:
Class Names for all the Classes you will need.
Field Names and Types
Method names with signatures. {you do not get need to present the method implementation}.
We will do this in 2 parts:
Part 1: Instructor will demonstrate making a Class Hierarchy for the College Enrollment System.
Part 2: Every student will receive their own personalized Business Domain: For Part B as Assignment 1, you will write a working Java Application.
For Assignment 1: Part 1: The SUD is The College Enrolllment System: What are the requirements for our College Enrollment System:
R 1: The System Shall Provide a way to record student enrollments. The Student List.
R 2: The System Shall Provide a way to maintain a class catalog which is the details of all the classes.
R 3: The System Shall Provide a functionality to generate student schedules.

Learning outcomes:
Progressively builds students' skills from OOP fundamentals to data structures and exception handling.
Java Lesson Plan: From OOP to Data Structures
Course Objectives
Understand core OOP concepts: classes, objects, inheritance, polymorphism, encapsulation, and abstraction.
Implement various Java data structures and understand their use cases.
Employ exception handling mechanisms to create robust code.
Lesson Structure
1. Review of Object-Oriented Programming (OOP) concepts:
We make Java Applications by constructing communities of Objects
We wire these objects up to communicate with:
Method calls/interactions
Shared Field Composition

The 2 ways to structure the architecture of our objects are:
A. Inheritance : “is a”
B. Composition : “ has a “

Concepts:
Classes and Objects
Inheritance and Polymorphism
Encapsulation and Abstraction
megaphone

Let's craft a Java program that showcases the concepts of Classes and Objects, Inheritance and Polymorphism, and Encapsulation and Abstraction:

// Illustration of Classes and Objects class Animal { // Attributes (Encapsulation) private String name; private int age;
// Constructor public Animal(String name, int age) { this.name = name; this.age = age; }
// Methods (Abstraction) public void makeSound() { System.out.println("Generic animal sound"); }
public String getName() { return name; }
public int getAge() { return age; } }
// Inheritance and Polymorphism class Dog extends Animal { public Dog(String name, int age) { super(name, age); }
// Method Overriding (Polymorphism) @Override public void makeSound() { System.out.println("Woof!"); } }
class Cat extends Animal { public Cat(String name, int age) { super(name, age); }
// Method Overriding (Polymorphism) @Override public void makeSound() { System.out.println("Meow!"); } }
public class AnimalDemo { public static void main(String[] args) { Animal animal = new Animal("Generic Animal", 5); Dog dog = new Dog("Buddy", 3); Cat cat = new Cat("Whiskers", 2);
animal.makeSound(); // Output: Generic animal sound dog.makeSound(); // Output: Woof! cat.makeSound(); // Output: Meow!
System.out.println(dog.getName() + " is " + dog.getAge() + " years old."); // Output: Buddy is 3 years old. } }
Explanation:
Classes and Objects:
The Animal, Dog, and Cat classes define blueprints for creating objects.
We create objects (animal, dog, cat) using the new keyword.
Objects have attributes (data) and methods (behavior).
Inheritance and Polymorphism:
Dog and Cat inherit from Animal, gaining its attributes and methods.
They override the makeSound() method, exhibiting polymorphism (different implementations of the same method).
The main method demonstrates how objects of different classes can be treated uniformly through the Animal reference.
Encapsulation and Abstraction:
Attributes like name and age are private, enforcing encapsulation (data hiding).
Accessor methods (getName(), getAge()) provide controlled access to the data.
The makeSound() method abstracts the implementation details of how an animal makes a sound.
This program effectively illustrates the fundamental OOP principles, providing a solid foundation for further exploration of Java programming.
Feel free to ask if you have any other questions or would like to see specific examples of other concepts!
Code Drills:
Create classes representing real-world entities (e.g., Car, Student).
Implement inheritance relationships (e.g., Animal -> Dog, Cat).
Demonstrate polymorphism through method overriding.
Use access modifiers to control data visibility.

2. Data Structures Overview
Concepts:
Arrays
Linked Lists
Stacks and Queues
Trees (Binary Trees, Binary Search Trees)
Hash Tables (HashMap, HashSet)
Catalog of Java Data Structures and Code Drills:
Arrays:
Declare and initialize arrays.
Access and modify elements.
Search and sort arrays.
Linked Lists:
Create nodes and link them.
Implement insertion, deletion, and traversal.
Stacks:
Push and pop elements.
Implement using arrays or linked lists.
Queues:
Enqueue and dequeue elements.
Implement using arrays or linked lists.
Trees:
Create nodes and establish parent-child relationships.
Implement traversal algorithms (preorder, inorder, postorder).
Binary Search Trees: insertion, deletion, and search.
Hash Tables:
Store key-value pairs.
Implement using HashMap and HashSet.
Handle collisions.
3. Exception Handling
Concepts:
try, catch, finally blocks
Types of exceptions (checked vs. unchecked)
Throwing and catching exceptions
Code Drills:
Handle potential exceptions (e.g., division by zero, array index out of bounds).
Create custom exceptions.
Use finally to ensure cleanup code execution.
Assessment
Assignments:
Design and implement OOP-based projects.
Implement data structures and algorithms.
Write code with robust exception handling.
Exams:
Evaluate conceptual understanding and coding skills.
Teaching Tips
Hands-on Practice: Emphasize coding exercises and projects to solidify learning.
Real-World Examples: Relate data structures and OOP concepts to real-world scenarios.
Debugging: Encourage students to develop debugging skills.
Collaboration: Foster peer learning through group activities.
Additional Considerations:
Prerequisites: Students should have a basic understanding of Java syntax and programming constructs.
Advanced Topics: For advanced learners, explore more complex data structures (e.g., graphs, heaps) and algorithms.
Tools: Utilize IDEs (e.g., Eclipse, IntelliJ IDEA) for code development and debugging.
This lesson plan provides a structured approach to guide students from OOP basics to data structures and exception handling, equipping them with essential skills for Java programming.

Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.