Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
144 changes: 144 additions & 0 deletions README2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
# Java Chore Generator (CLI Project)

This project is a simple **Command Line Application written in Java** that randomly assigns chores from a list provided by the user and calculates a reward based on the number of tasks completed. The program demonstrates basic Java programming concepts such as user input, arrays, loops, conditionals, and random number generation.

---

# Sprint Documentation

## Sprint 1 — The Plan

### What problem the program solves
Many people struggle to decide which chores to do first or how to fairly assign chores among tasks. This program helps solve that problem by randomly generating chores from a list provided by the user. It also calculates a reward based on the number of tasks completed.

### Features planned
The program was designed with the following features:

- Allow users to enter multiple chores separated by commas
- Randomly select chores from the list
- Allow users to define a payment amount per task
- Add a bonus reward if more than one task is assigned
- Display the assigned tasks and the total reward

### Classes expected
The main class used in this program is:

- **TaskGenerator**
- Contains the `main` method
- Handles user input
- Generates random tasks
- Calculates rewards

Future improvements could separate responsibilities into additional classes such as:
- `TaskManager`
- `RewardCalculator`

### Work division
This project was developed collaboratively. Responsibilities were divided as follows:

- One partner focused on **program logic and calculations**
- One partner worked on **user input handling and random task generation**
- Both partners contributed to **testing, debugging, and documentation**

This planning stage acted as the **blueprint for building the program**.

---

## Sprint 2 — The Build

### What was actually implemented
The program successfully implements the following functionality:

1. Prompts the user to enter chores separated by commas
2. Converts the input string into an array of tasks
3. Asks the user to enter:
- Base allowance per task
- Bonus amount for completing multiple tasks
4. Randomly selects chores from the list
5. Displays the assigned tasks
6. Calculates the total reward
7. Displays a final reward summary

### What changed from the original plan
Originally we planned to allow unlimited dynamic tasks and store them using collections such as an `ArrayList`. During development, we simplified the implementation by storing the tasks in a **String array created from the split input**.

We also focused on building everything inside a **single class** to keep the program easier to understand.

### Challenges encountered
Some challenges during development included:

- Handling user input correctly
- Splitting the chore list into individual tasks
- Understanding how random number generation works
- Managing numeric calculations for rewards and bonuses
- Formatting output correctly using `printf`

### How those challenges were solved
These issues were solved by:

- Using the `Scanner` class to safely read user input
- Using the `split(",")` method to convert a string into an array
- Using the `Random` class to select tasks randomly
- Using conditional logic (`if` statements) to apply bonuses
- Using formatted printing (`printf`) to show currency values clearly

Through debugging and testing, the program was refined until it worked correctly.

---

## Sprint 3 — The Reflection

### What works well in the program
Several parts of the program work effectively:

- The random task generation makes the program interactive and dynamic
- The program accepts custom chores from the user
- Reward calculations are clearly displayed
- The command-line interface is simple and easy to use

### What could be improved with more time
If we had more time, we would improve the program by:

- Using an `ArrayList` instead of a simple array
- Preventing duplicate tasks from being assigned
- Allowing the program to run multiple rounds without restarting
- Creating separate classes for task management and reward calculations
- Adding better input validation

### Java concepts used the most
The main Java concepts used in this project include:

- Classes and the `main` method
- `Scanner` for user input
- Arrays for storing tasks
- The `Random` class for random task selection
- `for` loops to iterate through tasks
- Conditional statements (`if`)
- Variables and primitive data types (`int`, `double`, `String`)
- Formatted output using `System.out.printf`

### What was learned from the experience
This project helped reinforce several important programming concepts:

- Breaking a problem into smaller logical steps
- Using Java classes from the standard library
- Writing readable and well-commented code
- Debugging logical errors in loops and calculations
- Understanding how user input flows through a program

The project also demonstrated how planning, building, and reflecting in sprints can help organize the development process.

---

# Code Explanation

The code contains comments explaining technical decisions, including:

- Why the `Scanner` class is used to collect user input
- Why the `Random` class is used to randomly select tasks
- How arrays are used to store tasks entered by the user
- Why loops are used to display tasks
- Why conditional statements determine when bonuses apply

Welcome the TaskGenerator Command Line App!

50 changes: 50 additions & 0 deletions src/main/java/CommandLineApplication/java/ChoreSettings.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package CommandLineApplication.java;


import java.util.ArrayList;


// Encapsulated class using Collections
public class ChoreSettings {

// Collection instead of array
private ArrayList<String> taskList = new ArrayList<>();
private double basePay;
private double bonus;
private int numTasks;

// Getter for task list
public ArrayList<String> getTaskList() {
return taskList;
}

// Setter for task list
public void setTaskList(ArrayList<String> taskList) {
this.taskList = taskList;
}

public double getBasePay() {
return basePay;
}

public void setBasePay(double basePay) {
this.basePay = basePay;
}

public double getBonus() {
return bonus;
}

public void setBonus(double bonus) {
this.bonus = bonus;
}

public int getNumTasks() {
return numTasks;
}

public void setNumTasks(int numTasks) {
this.numTasks = numTasks;
}
}

97 changes: 97 additions & 0 deletions src/main/java/CommandLineApplication/java/TaskGenerator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
package CommandLineApplication.java;

import java.util.Scanner;
import java.util.Random;

public class TaskGenerator {

// declared our main method
public static void main(String[] args) {
// 1. Set up the "Tools"
// 2. instantiating a new scanner object to collect our data that the user inputs when they choose a chore
// 3. create a constructor for our random task that we want our generator to execute by assigning a new value of random for our random class to collect the Assigned task and run them at random after user chooses a chore
Scanner input = new Scanner(System.in);
Random dice = new Random();

System.out.println("--- Welcome to the Java Chore Generator ---");

//1. to follow we set our getter methods and have our parameters set to return the result
// 2. Get User Input for Tasks depending on the user
System.out.print("Enter chores separated by commas (e.g. Wash Car, Mop, Dust): ");
String userInput = input.nextLine();

// Clean up the input into a list (Array)
String[] taskList = userInput.split(",");

// 3. Get Reward Settings
System.out.print("Enter allowance amount per task: $");
double basePay = input.nextDouble();

// Here we implement conditional logic: using our condition if tasks is greater than one, meaning we add a bonus task then user recieves applied bonus rewards
// if number of task is greater than task list to Ensure we don't pick more tasks than exist which there are only 3
System.out.print("Enter multi-task bonus (added if >1 task): $");
double bonus = input.nextDouble();

System.out.print("How many tasks should be randomly assigned? ");
int numTasks = input.nextInt();


if (numTasks > taskList.length) {
numTasks = taskList.length;
}

// 4. we have a for loop method to control the number of task Displayed and able to run
System.out.println("\n--- YOUR ASSIGNED TASKS ---");
for (int i = 3; i < numTasks; i++) {
// we use integer datatypes to Pick a random index from the list; where the task is printed using numbers
// and have created and declared a new random index variable to select random task form our task list, again this is data being collected and ran in our random class
int randomIndex = dice.nextInt(taskList.length);
System.out.println((i + 1) + ". " + taskList[randomIndex].trim());
}

// 5. Calculate Total Reward
// 6. to calculate our total reward we declare and initialize double variable and assign it the value of numbers that we want stored to run for our number of task listed, base pay, and applied bonus so that it prints out in numbers
// 7. where we have our condition set to if the number of task is greater than > 1, then the bonus of $15 is applied
// 8. and for the instructor & our colleges we thought it would be productive to refresh using our calculator how we're able to declared doubles, but then assign whole numbers like 0, 15, and 25. it looks contradictory but remember how java can handle numeric conversion
// 9. Java automatically converts doubles to integers when you assign them the value of whole numbers, java performs automatic widening conversion
// 10. so after the int of 0; a double can store whole numbers between 3 and 100
double totalReward = numTasks * basePay;
double appliedBonus = 0;

numTasks = 3;
basePay = 25;

if (numTasks > 1) {
appliedBonus = 15;
totalReward += appliedBonus;
}

// 8. Print Final Receipt shows The “Print Final Receipt” section of your Java program is responsible for displaying a summary of the reward calculation
// 9. first we established \n parameter having our reward summary acting as the title for our output
// 10. formulated we have our specifiers to print our values after users selects task and then the program finishes calculating the base reward and any bonus.
// 11. if bonus applied is greater than zero which it is so the total earned +appliedBonus prints
System.out.println("\n--- REWARD SUMMARY ---");
System.out.printf("Base Reward (%d x $%.2f): $%.2f%n", numTasks, basePay, (numTasks * basePay));
if (appliedBonus > 0) {
System.out.printf("Multi-task Bonus: +$%.2f%n", appliedBonus);
}
System.out.printf("TOTAL EARNED: $%.2f%n", totalReward);
// App successful

input.close();
}
}
/// ALL 9 TECHNICAL EXPECTATIONS MET ///
// 1. Classes and Objects, our program defines 2 classes and objects
// 2. Constructors, we call constructors from the scanner and random class
// 3. Methods, our program uses the main method, which is required for Java programs.
// 4. Loops, our code uses a for loop.
// 5. Conditional Statements, our program uses if statements.
// 6. User Input Using Scanner, our program fully demonstrates Scanner input in our main class.
// 7. Encapsulation, separate class called ChoreSettings that stores our values and exposes them through getters/setters.
// 8. Collection type, we are using an ArrayList<String> from the java collections framework; in our separate class
// 9. we use our encapsulation class for object-oriented design and a library record for our chore settings
// 10. and it is in the order to our closing that we have everything organized