so I started this but I\'m confused public class Chore { private boolean isCompl
ID: 3763193 • Letter: S
Question
so I started this but I'm confused
public class Chore
{
private boolean isCompleted;
private String Chore;
private int points;
private int frequency;
I already set it out how I want to write it like what it should do
Chore class
+addChore()
+deleteChore()
+setPoints()
+setChoreFrequency()
+isCompleted()
-Should reset frequency as well
-Should assign points to the user that marked completed
-Should store Date completed
+choreHistory()
-should store Date and User that completed the chore
I understand the setters its pretty easy my question is for the addChore and remove chore do i need another class container? i would i write it here and does it apply to the chore history too..
.. and I'm using java.. thanks
Explanation / Answer
public class Main
{
public static void main(String[] args)
{
ArrayBag choreList = new ArrayBag<>();
int input;
String chore;
boolean endProgram=false;
Scanner keyboard = new Scanner(System.in);
while(!endProgram)
{
System.out.println("Select your option from the list.");
System.out.println();
System.out.println("Add item to list(press 1)");
System.out.println("View number of items on list(press 2)");
System.out.println("View a list of chores(press 3)");
System.out.println("Delete an item from the list(press 4)");
System.out.println("Exit program(press 5)");
entry = keyboard.nextInt();
switch(input)
{
case 1: System.out.println();
System.out.println("What would you like to add?");
chore = keyboard.nextLine();
choreList.add(chore);
break;
case 2: System.out.println();
System.out.println("There are " + choreList.size() + " items on your list.");
break;
case 3: System.out.println();
choreList.printList();
break;
case 4: System.out.println();
System.out.println("Which item would you like to delete?");
chore = keyboard.nextLine();
choreList.remove(chore);
break;
case 5: endProgram=true;
break;
} }
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.