Share
Explore

Project Title: Java Storytellers

Project Title: Java Storytellers - From Sketch to Code

Project Grading Rubric:

Delivering the Project:

To get a passing Grade: I will run your Program 10 times. The Turtle should win at least 7 times out of 10.
The hand in for your project:
Make a Word Document - save as StudentName_studentid.docx

Into this Word Document:
Put all your Code
Screen shots of the Running Program.

Where to upload your Word Document Submission File:

megaphone

Grading rubric for the Tortoise and Hare race project, designed to evaluate the core Java concepts and the storytelling elements.

Grading Rubric (100 points total)
Functionality (50 points)
Race Logic (15 points)
Race correctly starts and ends based on the defined distance.
Tortoise and Hare move according to their defined speeds.
Winner is accurately declared (including ties).
Hare Distraction (15 points):
Hare has the ability to get distracted with a reasonable probability.
Distraction has a clear consequence (e.g., pausing, losing progress).
Hare can potentially regain focus.
Optional: Tortoise Determination (10 points)” This requires some work on your part: Study and modify the starter code:
Tortoise gains a slight advantage if the Hare gets distracted or naps.
The advantage is incremental and logical.
Code Structure and Readability (10 points)
What you need to do Include with your project submission UML diagrams of the type we presented in class to show UML field composition between classes and object interactions via method calls between objects.
Object-Oriented Design (30 points)
Classes and Inheritance (15 points)
RaceParticipant superclass is appropriately defined.
Tortoise and Hare subclasses demonstrate inheritance.
Methods like move are effectively overridden for specific behaviors.
Add to the provided starter code for frequent race status updates displayed to the console.
Exception Handling (15 points): This will require some work on your part to increase the turtle’s chance of winning.
Modify the exception handling to make the rabbit get distracted more easily.
Storytelling and Creativity (20 points)
Modify the provided Starter Code so that the Turtle usually wins: This is your work to do.



How to do this project: https://app.screencast.com/8pgDAYqXpx3vY


Submission Instructions: Due: APRIL 14, 2024

Put your business analysis and code into a Word Document - named as StudentName_StudentID.docx
Upload to: The Dropbox Location Posted in Google Classroom

Objective:

To design and implement a Java application that tells a story, beginning with a hand-drawn analysis of the story's business domain, and then translating that analysis into object-oriented code.
megaphone

🌟 Welcome to the Java Storytellers Project! 🌟

Embark on a Journey of Creativity and Code

Code meets creativity.
Logic intertwines with lore, and where every line of Java brings a story to life

This isn't just another coding assignment – it's an adventure into the heart of programming, storytelling, and imagination.
In the Java Storytellers Project, you'll embark on a unique mission:
**to transform a narrative of your choice into a living, breathing Java application**.
But this is no ordinary task. You'll be breathing life into characters, crafting digital worlds, and setting the stage for events that unfold through the logic and structure of Java.
#### 📖 Your Quest: From Story to Software
You will choose a story – a tale you love, a fable you admire, or maybe even a saga of your own creation – and turn it into an interactive Java experience. This story will be your blueprint; your code, the building blocks.
🚀 Unleash Your Imagination
- **Design with Flair**: Craft your story's characters, settings, and plots as Java objects. What attributes will they have? What methods will allow them to interact within your digital realm? - **Inheritance and Polymorphism**: Use the power of Java's inheritance to define relationships between your story's entities. Watch as polymorphism brings versatility and depth to your narrative. - **Exceptional Circumstances**: Implement custom exceptions to handle the unexpected twists and turns of your tale.
#### 🧰 Tools and Techniques
Arm yourselves with Java's powerful toolkit: - The JDK as your forge. - Integrated Development Environments (IDEs) as your workshop. - Version control for collaboration and keeping track of your epic journey.
#### 🌌 Why This Journey Matters
This isn't just about fulfilling an assignment. It's about mastering the art of translating abstract concepts into concrete, functional programs. It's about understanding that at the core of every complex program is a simple story, waiting to be told.

Overview:

Students will conceptualize a story and represent it through a series of interconnected objects. This project starts with a hand-drawn design of these objects, their attributes, and interactions, serving as a preliminary business domain analysis. Students will then translate this design into a functional Java application.

Project Phases:

Phase 1: Conceptualization and Domain Analysis

Story Development:
Select a simple, engaging story.
Identify key elements like characters, items, and locations.
Hand-Drawn Object Design:
Draw each object that forms part of the story.
Label each object with a name.
For each object, list down the data attributes and methods.
Consider how objects share fields (composition) and how they might interact through method calls.
Documentation:
Take a clear picture of these hand-drawn designs with a cell phone.
In a Word document, include these images.
Write a brief description of the story and explain how each object fits within this narrative.
Highlight that this process is akin to a business domain analysis, a crucial step before code development.

Phase 2: Code Development

Class Design:
Translate the hand-drawn objects into Java classes.
Implement fields, constructors, and methods as per the design.
Inheritance and Polymorphism:
Implement inheritance and polymorphism where applicable.
Object Interactions:
Code the interactions between objects as per the design.
Exception Handling:
Implement custom exceptions to handle any unusual or unexpected story turns.

Phase 3: Finalization and Presentation

Documentation and Reflection:
Finalize the documentation with a detailed description of the implementation and reflection on the process.
Project Presentation:
Present the project, showcasing the original designs and the final application.

Submission:

Submit the Word document containing the hand-drawn designs and story description.
Include the Java source files.
A README file with instructions to run the application.
Reflection on the process and learning.

Evaluation Criteria:

Domain Analysis: Quality and clarity of the initial hand-drawn designs and story description.
Story and Code Integration: How effectively the story is translated into code.
Application of OOP Principles.
GUI Implementation (if applicable).
Overall Documentation and Reflection.
Presentation Skills.

Deadline:

APRIL 14, 2024
Put your business analysis and code into a Word Document - named as StudentName_StudentID.docx
Upload to: The Dropbox Location posted in Google Classroom.

Present a representative business domain analysis telling the story of the tortoise and the hare. The rabbit thought it was faster but fooled around and got distracted. The turtle won the race by staying focused and on task. Emphasize that this is just a starter example and they should imagine their own business domain to model.
Let's create a simplified business domain analysis for the story of the Tortoise and the Hare. This example will serve as a starting point to illustrate how a story can be broken down into a domain model, which can then be translated into an object-oriented design. Students should use this as a guide to develop their own unique domain models for their stories.

Business Domain Analysis: The Tortoise and the Hare

1. Story Overview

Theme: A race between the Tortoise and the Hare.
Moral: Slow and steady wins the race.

2. Main Characters (Objects)

Tortoise
Attributes: speed, distanceCovered, isFocused.
Methods: move(), checkProgress().
Hare
Attributes: speed, distanceCovered, isDistracted.
Methods: move(), getDistracted(), checkProgress().

3. Supporting Elements

Race
Attributes: distance, isFinished.
Methods: startRace(), checkStatus(), declareWinner().

4. Interactions

The Race object initializes and starts the race.
Both Tortoise and Hare objects participate in the race by invoking their move() method.
The Hare may invoke getDistracted() leading to decreased distanceCovered.
The Tortoise remains consistent in its move() method, representing its focused nature.
Race checks the progress of each competitor and declares the winner once the race is finished.

5. Relationships

Tortoise and Hare are in a competitive relationship, both participating in the Race.
The Race has a controlling relationship over the Tortoise and the Hare, dictating the start and end of the race.

6. Process Flow

Race starts → Tortoise moves steadily → Hare moves quickly but gets distracted → Tortoise maintains focus and continues moving → Race ends → Winner is declared based on distance covered.

7. Potential Extensions

Implement a Spectator object to observe and react to the race.
Introduce environmental factors impacting the race (e.g., weather conditions).

8. Visual Representation

A simple diagram can be drawn, showing the Tortoise and the Hare with their attributes and methods. Additionally, the Race object can be depicted with its controlling methods over the participants.

Note to Students:

This example serves as a basic guideline. For your project, be imaginative and create a unique business domain to model. Think of a story or scenario that interests you, identify the key objects, their attributes, methods, and how they interact within your story. Remember, the more creative and detailed your analysis, the more robust your object-oriented design will be.

A skeleton code framework to show them a structure of how to get started
Below is a skeleton code framework for the Tortoise and the Hare story.
This will provide students with a basic structure to start their Java projects. It's important to note that this is a simplistic example, and students should expand and modify it to fit their chosen stories.
javaCopy code
// Main class to initiate and control the race
public class RaceController {
public static void main(String[] args) {
Race race = new Race(100); // 100 meters race
Tortoise tortoise = new Tortoise(10); // speed in meters per minute
Hare hare = new Hare(25); // speed in meters per minute

race.startRace(tortoise, hare);
}
}

// Race class
class Race {
private int distance;
private boolean isFinished;

public Race(int distance) {
this.distance = distance;
this.isFinished = false;
}

public void startRace(Tortoise tortoise, Hare hare) {
// Implement race logic here
}

// Additional methods like checkStatus, declareWinner can be added
}

// Tortoise class
class Tortoise {
private int speed;
private int distanceCovered;

public Tortoise(int speed) {
this.speed = speed;
this.distanceCovered = 0;
}

public void move() {
// Implement movement logic for Tortoise
}

// Additional methods like checkProgress can be added
}

// Hare class
class Hare {
private int speed;
private int distanceCovered;
private boolean isDistracted;

public Hare(int speed) {
this.speed = speed;
this.distanceCovered = 0;
this.isDistracted = false;
}

public void move() {
// Implement movement logic for Hare
}

public void getDistracted() {
// Implement distraction logic for Hare
}

// Additional methods like checkProgress can be added
}

Instructions for Students:

Understand the Framework: Analyze the provided skeleton code to understand how each class represents an entity in the story.
Expand the Classes: Add more attributes and methods to each class as per your story's requirements. Think about what characteristics and behaviors your objects should have.
Implement Logic: Write the logic for the methods. For example, how does the move method change the distanceCovered for the Tortoise and the Hare?
Interaction: Focus on how the objects interact with each other. In the example, the Race controls the Tortoise and the Hare.
Customize for Your Story: Adapt this framework to fit the narrative and objects of your chosen story. Add new classes, methods, and logic as needed.
Test and Debug: Run your code frequently to test for correctness and fix any issues.
Document Your Code: Add comments to explain your code for clarity and future reference.
This framework is meant to be a guide. Encourage creativity and innovation in translating your story into a well-structured object-oriented program.

Illustrative code of how inheritance and polymorphism may be applied here.
To illustrate inheritance and polymorphism in the context of the Tortoise and the Hare story, we can introduce a superclass, perhaps RaceParticipant, from which both Tortoise and Hare classes will inherit.
This superclass will define common attributes and methods that are shared by both tortoise and hare. We'll then use method overriding to demonstrate polymorphism.
Here's how this can be structured:

Superclass: RaceParticipant

javaCopy code
public abstract class RaceParticipant {
protected int speed;
protected int distanceCovered;

public RaceParticipant(int speed) {
this.speed = speed;
this.distanceCovered = 0;
}

public abstract void move(); // Abstract method to be implemented in subclasses

public int getDistanceCovered() {
return distanceCovered;
}

// Other common methods can be added here
}

Subclasses: Tortoise and Hare

javaCopy code
public class Tortoise extends RaceParticipant {

public Tortoise(int speed) {
super(speed);
}

@Override
public void move() {
// Specific implementation for Tortoise
distanceCovered += speed; // Tortoise moves at a constant speed
}
}

public class Hare extends RaceParticipant {

private boolean isDistracted;

public Hare(int speed) {
super(speed);
this.isDistracted = false;
}

@Override
public void move() {
if (!isDistracted) {
distanceCovered += speed; // Hare moves faster when not distracted
} else {
// Hare is distracted and does not move
}
}

public void getDistracted() {
isDistracted = true;
}

// Method to regain focus
public void regainFocus() {
isDistracted = false;
}
}

Illustration of Polymorphism

In the RaceController class, we can now interact with both Tortoise and Hare objects through their superclass type RaceParticipant, demonstrating polymorphism.

public class RaceController {
public static void main(String[] args) {
Race race = new Race(100);
RaceParticipant tortoise = new Tortoise(10);
RaceParticipant hare = new Hare(25);

race.startRace(tortoise, hare);
}
}
In this setup, both Tortoise and Hare are RaceParticipants, but they each have their unique implementation of the move method.
This illustrates the concept of polymorphism, where a single interface (in this case, the move method) can be implemented in different ways by different classes.

Note for Students:

Understand how superclass and subclasses are related and how they share common properties.
Observe how method overriding is used to provide specific implementations in subclasses.
Notice how polymorphism allows us to use objects of subclasses where instances of the superclass are expected. This enhances flexibility and scalability in your code.

Illustrative code of how exception handling may be applied here.
To incorporate exception handling into the Tortoise and the Hare story, we can introduce a custom exception.
For example, let's create an exception that occurs when the Hare gets too distracted, leading to a race interruption. This scenario will demonstrate how to define and handle exceptions in Java.

Step 1: Define a Custom Exception

public class TooDistractedException extends Exception {
public TooDistractedException(String message) {
super(message);
}
}

Step 2: Modify the Hare Class to Throw the Exception

We'll adjust the Hare class so that if it becomes too distracted, it throws a TooDistractedException.
public class Hare extends RaceParticipant {

private boolean isDistracted;
private int distractionCount;

public Hare(int speed) {
super(speed);
this.isDistracted = false;
this.distractionCount = 0;
}

@Override
public void move() throws TooDistractedException {
if (!isDistracted) {
distanceCovered += speed; // Hare moves faster when not distracted
} else {
distractionCount++;
if (distractionCount > 3) { // Arbitrary condition for being too distracted
throw new TooDistractedException("Hare is too distracted to continue the race!");
}
}
}

public void getDistracted() {
isDistracted = true;
}

public void regainFocus() {
isDistracted = false;
}
}

Step 3: Modify the RaceController to Handle the Exception

We need to handle the TooDistractedException in the RaceController class where the race logic is executed.
javaCopy code
public class RaceController {
public static void main(String[] args) {
Race race = new Race(100);
RaceParticipant tortoise = new Tortoise(10);
Hare hare = new Hare(25);

try {
race.startRace(tortoise, hare);
} catch (TooDistractedException e) {
System.out.println(e.getMessage());
// Additional logic to handle the exception can be placed here
}
}
}

Note for Students:

Custom exceptions like TooDistractedException are a way to create your own specific error types that are relevant to your application's logic.
By throwing and catching these exceptions, you can control the flow of your program and handle error conditions more gracefully.
This example illustrates how exceptions are not just for error states but can represent any significant diversion from the normal flow of logic, such as the Hare becoming too distracted to continue the race.


image.png

Here is the completed version of this program:

// program in operation: https://app.screencast.com/NQZGVc5iWsAMS import java.util.Random;
public class RaceController { private static final int RACE_DISTANCE = 100;
public static void main(String[] args) { Race race = new Race(RACE_DISTANCE); Tortoise tortoise = new Tortoise(10); Hare hare = new Hare(25);
race.startRace(tortoise, hare); }
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.