URGENT
I have 3 hours for Submit this Homework so you can share yout codes with me in 150mins
package AliCelik198322344;
class Customer{
String name;
String address;
double dailydemand;
Customer(){}
Customer(String n,String a,double d){
this.name=n;
this.address=a;
this.dailydemand=d;
}
public void setName(String name){
this.name=name;
}
public String getName(){
return name;
}
public void setAddress(String address){
this.address=address;
}
public String getAddress(){
return address;
}
public void setDailydemand(double dailydemand){
this.dailydemand=dailydemand;
}
public double getDailydemand(){
return dailydemand;
}
public String toString(){
return this.name+" - "+this.address+"
["+this.dailydemand+" ]";
}
}
package AliCelik198322344;
import java.util.ArrayList;
class CustomerBook{
ArrayList<Customer> customers=null;
CustomerBook(){
customers=new
ArrayList<Customer>();
}
public void addCustomer(Customer customer){
customers.add(customer);
}
public ArrayList<Customer> getCustomersAt(String
address){
ArrayList<Customer>
matchedCustomers=new ArrayList<Customer>();
if(customers!=null &&
customers.size()>0){
for(Customer
customer:customers){
if(customer.getAddress().equals(address))
matchedCustomers.add(customer);
}
}
return matchedCustomers;
}
}
package AliCelik198322344;
import java.util.ArrayList;
import java.util.List;
import java.util.Arrays;
class Map{
String addresses[]=null;
double distances[][]=null;
Map(String[] addresses,double[][] distances){
this.addresses=addresses;
this.distances=distances;
}
int findAddress(String address){
int index=-1;
for(int
i=0;i<addresses.length;i++){
if(addresses[i].equals(address))
index=i;
}
return index;
}
double distanceBetween(String address1,String
address2){
double distance=-1;
int index1=-1;
int index2=-1;
for(int
i=0;i<addresses.length;i++){
if(addresses[i].equals(address1))
index1=i;
if(addresses[i].equals(address2))
index2=i;
}
if(index1!=-1 || index2!=-1){
distance=distances[index1][index2];
}
return distance;
}
ArrayList<String> getAddresses(){
ArrayList<String>
addressesList=new ArrayList<String>();
if(addresses!=null &&
addresses.length>0)
{
for(String
address:addresses)
addressesList.add(address);
}
return addressesList;
}
}
package AliCelik198322344;
import java.util.ArrayList;
abstract class MilkTruck{
String name;
double currentMilk;
String currentAddress;
double distanceTraveled;
static double TotalDistanceTraveled;
static double TruckCapacity;
static double TotalMilkDelivered;
MilkTruck(String name,String currentAddress){
this.name=name;
this.currentAddress=currentAddress;
this.currentMilk=TruckCapacity;
this.distanceTraveled=0;
}
boolean visitAddress(CustomerBook customerBook,Map
map,String address){
boolean flag=true;
return
flag;
}
abstract void deliverMilk(CustomerBook
customerBook,Map map);
}
package AliCelik198322344;
import java.util.ArrayList;
class RandomDelivery extends MilkTruck{
RandomDelivery(String name,String
currentAddress){
super(name,currentAddress);
}
void deliverMilk(CustomerBook customerBook,Map
map){
System.out.println("Random Truck
Started Delivery");
System.out.println("------------------------------------------------");
this.distanceTraveled=0;
this.currentMilk=100;
TruckCapacity=100;
TotalMilkDelivered=0;
TotalDistanceTraveled=0;
ArrayList<String>
visitedAddresses = new ArrayList<String>();
System.out.println("The
Address:"+currentAddress+" visited, Distance
Travelled:"+this.distanceTraveled);
System.out.println("The Address:"+currentAddress+" visited,
Distance Travelled:"+this.distanceTraveled);
ArrayList<Customer>
customers=customerBook.getCustomersAt(currentAddress);
if(customers!=null && customers.size()>0){
for(Customer customer:customers){
this.currentMilk=this.currentMilk-customer.getDailydemand();
TruckCapacity=TruckCapacity-customer.getDailydemand();
TotalMilkDelivered=TotalMilkDelivered+customer.getDailydemand();
TotalDistanceTraveled=
distanceTraveled;
System.out.println("Customer
"+customer.getName()+" is delivered. Delivered Milk :
"+customer.getDailydemand()+" Current
Milk:"+this.currentMilk);
}
}
printStats();
visitedAddresses.add(currentAddress);
for(String
address:map.getAddresses()){
boolean visited=false;
String
prevAddress=currentAddress;
for(String
addr:visitedAddresses){
if(addr.equals(address))
visited=true;
}
if(visited==false && TruckCapacity>0){
currentAddress=address;
this.distanceTraveled=this.distanceTraveled+map.distanceBetween(prevAddress,currentAddress);
System.out.println("The
Address:"+currentAddress+" visited, Distance
Travelled:"+this.distanceTraveled);
TotalDistanceTraveled=TotalDistanceTraveled+distanceTraveled;
ArrayList<Customer>
customersAtAddress=customerBook.getCustomersAt(currentAddress);
if(customersAtAddress!=null &&
customersAtAddress.size()>0){
for(Customer customer:customersAtAddress){
this.currentMilk=this.currentMilk-customer.getDailydemand();
TruckCapacity=TruckCapacity-customer.getDailydemand();
TotalMilkDelivered=TotalMilkDelivered+customer.getDailydemand();
System.out.println("Customer
"+customer.getName()+" is delivered. Delivered Milk :
"+customer.getDailydemand()+" Current
Milk:"+this.currentMilk);
}
printStats();
visitedAddresses.add(currentAddress);
}
}
}
}
void printStats(){
System.out.println("Current
Address:"+currentAddress);
System.out.println("Current
Milk:"+currentMilk);
System.out.println("Total
Milk:"+TotalMilkDelivered);
System.out.println("Distance
Travelled:"+distanceTraveled);
System.out.println("Total
Distances:"+TotalDistanceTraveled);
}
}
package AliCelik198322344;
import java.util.ArrayList;
class NearestAddressFirst extends MilkTruck{
NearestAddressFirst(String name,String
currentAddress){
super(name,currentAddress);
}
void deliverMilk(CustomerBook customerBook,Map
map){
System.out.println("\n\nNearest
Truck Started Delivery");
System.out.println("--------------------------------------");
this.distanceTraveled=0;
this.currentMilk=100;
TruckCapacity=100;
TotalMilkDelivered=0;
int
toBeVisited=map.addresses.length;
ArrayList<String>
visitedAddresses = new ArrayList<String>();
System.out.println("The Address:"+currentAddress+" visited,
Distance Travelled:"+this.distanceTraveled);
TotalDistanceTraveled=distanceTraveled;
ArrayList<Customer>
customers=customerBook.getCustomersAt(currentAddress);
if(customers!=null && customers.size()>0){
for(Customer customer:customers){
this.currentMilk=this.currentMilk-customer.getDailydemand();
TruckCapacity=TruckCapacity-customer.getDailydemand();
TotalMilkDelivered=TotalMilkDelivered+customer.getDailydemand();
System.out.println("Customer
"+customer.getName()+" is delivered. Delivered Milk :
"+customer.getDailydemand()+" Current
Milk:"+this.currentMilk);
}
}
printStats();
visitedAddresses.add(currentAddress);
toBeVisited=toBeVisited-1;
//find shortest
distance address
String
prevAddress=currentAddress;
while(toBeVisited>0){
double
distance=0.0;
for(String
address:map.getAddresses()){
double newdistance=0.0;
boolean visited=false;
for(String
addr:visitedAddresses){
if(addr.equals(address))
visited=true;
}
if(visited==false &&
!address.equals(currentAddress)){
newdistance=map.distanceBetween(currentAddress,address);
if(newdistance<distance){
distance=newdistance;
currentAddress=address;
}
}
}
if(!prevAddress.equals(currentAddress)){
System.out.println("The
Address:"+currentAddress+" visited, Distance
Travelled:"+this.distanceTraveled);
TotalDistanceTraveled=TotalDistanceTraveled+distanceTraveled;
customers=customerBook.getCustomersAt(currentAddress);
if(customers!=null && customers.size()>0){
for(Customer customer:customers){
this.currentMilk=this.currentMilk-customer.getDailydemand();
TruckCapacity=TruckCapacity-customer.getDailydemand();
TotalMilkDelivered=TotalMilkDelivered+customer.getDailydemand();
System.out.println("Customer
"+customer.getName()+" is delivered. Delivered Milk :
"+customer.getDailydemand()+" Current
Milk:"+this.currentMilk);
}
}
printStats();
visitedAddresses.add(currentAddress);
}
toBeVisited=toBeVisited-1;
}
}
void printStats(){
System.out.println("Current
Address:"+currentAddress);
System.out.println("Current
Milk:"+currentMilk);
System.out.println("Total
Milk:"+TotalMilkDelivered);
System.out.println("Distance
Travelled:"+distanceTraveled);
System.out.println("Total
Distances:"+TotalDistanceTraveled);
}
}
package AliCelik198322344;
class TestCode{
public static void main(String ar[]){
Map map=new Map(new
String[]{"A","B","C"}, new
double[][]{{0.0,3.0,5.0},{3.0,0.0,1.0},{5.0,1.0,0}});
CustomerBook customerList=new
CustomerBook();
customerList.addCustomer(new
Customer("Ali", "A",20));
customerList.addCustomer(new
Customer("Ayse", "A",30));
customerList.addCustomer(new
Customer("Berk", "B",10));
customerList.addCustomer(new
Customer("Can", "C",15));
customerList.addCustomer(new
Customer("Cemile", "C",35));
customerList.addCustomer(new
Customer("Ceyhun", "C",5));
MilkTruck mtRandom = new
RandomDelivery("RandomTruck","A");
MilkTruck mtNearest = new
NearestAddressFirst("Nearest Truck","B");
mtRandom.deliverMilk(customerList,map);
mtNearest.deliverMilk(customerList,map);
}
}
URGENT I have 3 hours for Submit this Homework so you can share yout codes with...
Hi. Could you help me with the code below? I need to validate the code below, using expressions that can carry out the actions or that make appropriate changes to the program’s state, using conditional and iterative control structures that repeat actions as needed. The unit measurement is missing from the final output and I need it to offer options to lbs, oz, grams, tbsp, tsp, qt, pt, and gal. & fl. oz. Can this be added? The final output...
please post ONLY flatratepackage.cpp, flateratepackage.h, package inventory.h and package inventory.cpp... Thank you! In this homework, you are going to write a program to represent various types of packages offered by package-delivery services. You need to create an inheritance hierarchy to represent various types of packages with different shipping options and associated costs. The base class is Package and the derived classes are FlatRatePackage and OvernightPackage. The base class Package includes the following attributes: • Sender information: senderName (string), senderAddress (string),...