Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Customer.java public class Customer { String name; String streetAddress; String city; boolean getsDaily,getsSunday; double amountDue; public Customer( String name, String streetAddress, String city , boolean

image text in transcribed

Customer.java

public class Customer { String name; String streetAddress; String city; boolean getsDaily,getsSunday; double amountDue; public Customer( String name, String streetAddress, String city , boolean getsDaily , boolean getsSunday , double amountDue) { this.name=name; this.streetAddress=streetAddress; this.city=city; this.getsDaily=getsDaily; this.getsSunday=getsSunday; this.amountDue=amountDue; } public String getName(){ return this.name; } public String getSteetAddress(){ return this.streetAddress; } public String getCity(){ return this.city; } public boolean getDaily(){ return this.getsDaily; } public boolean getSunday(){ return this.getsSunday; } public double getAmountDue(){ return this.amountDue; } public void setName(String name ){ this.name=name; } public void setSteetAddress(String streetAddress){ this.streetAddress=streetAddress; } public void setCity(String city){ this.city=city; } public void setDaily(boolean getsDaily){ this.getsDaily=getsDaily; } public void setSunday(boolean getsSunday){ this.getsSunday=getsSunday; } public void getAmountDue(double amountDue){ this.amountDue=amountDue; } public String toString(){ return "[ name : " + this.name + ", streetAddress : " + this.streetAddress + ", city : " + this.city + " , getsDaily : " + this.getsDaily + ", getsSunday : " + this.getsSunday + ", amountDue : " + this.amountDue + " ] " ; } }

PaperRoute.java

import java.util.ArrayList; import java.util.List; public class PaperRoute { List customerList =new ArrayList(); public void addCustomer(String name , String streetAddress, String city , boolean getsDaily , boolean getsSunday , double amountDue) { customerList.add(new Customer(name,streetAddress,city,getsDaily,getsSunday,amountDue)); } void displayAll(){ for(Customer c : customerList ) System.out.println(c); } double totalDue(){ double amount=0; for(Customer c : customerList ){ amount=amount + c.getAmountDue(); } return amount; } int countBySubscriptionType(String kind){ int count=0; if(kind.equals("daily")){ for(Customer c : customerList ) if(c.getDaily()) count++; } else if(kind.equals("sundays")){ for(Customer c : customerList ) if(c.getSunday()) count++; } return count; } }

Main.java

public class Tester { public static void main (String[] args) throws java.lang.Exception { PaperRoute myRoute=new PaperRoute(); myRoute.addCustomer("a","a","a",true,false,100.00); myRoute.addCustomer("b","b","b",false,true,110.00); myRoute.addCustomer("c","c","c",true,true,150.00); myRoute.addCustomer("d","d","d",true,false,120.00);

System.out.println("Displaying all customers in myRoute"); myRoute.displayAll(); System.out.println();

int count= myRoute.countBySubscriptionType("sundays"); System.out.println("Count according to type is : "+count); System.out.println(); double amt= myRoute.totalDue(); System.out.println("Total Due amount is " + amt); } }

Revise the project accordingly to add a method listAccounts() that will display information about each Customer in the collection of Customer you maintained in your class Paper Route use the comparable interface so that when you ask to list the Customers, the list will be displayed with the Customers that owe the most money shown first (i.e., in descending order), and then by alphabetical name. [So we'd say list will be sorted amountDue descending, name ascending.) Hints: 1. Of course, if Customer is Comparable, it will need a compareTo() method 2. We will want to use sort(....) to change the order of the ArrayList: you'll need to use the name of your ArrayList. Deliverable: The usual -- zip of Eclipse project directory, plus Word doc or individual; files with screen shot(s) of test run(s). Upload file(s) as needed, and use "Comment" textbox as needed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL For Data Science Data Cleaning Wrangling And Analytics With Relational Databases

Authors: Antonio Badia

1st Edition

3030575918, 978-3030575915

More Books

Students also viewed these Databases questions

Question

=+ a. a family deciding whether to buy a new car

Answered: 1 week ago

Question

=+10. How are inflation and unemployment related in the short run?

Answered: 1 week ago