QuestionQuestion

Create an app that displays a list of books and associated data using recycler view - each item in the view.

1. The app should display list of books from the database.
2. Each item should display Title, Author and Year published; and items should be separated using a divider or separator.
3. When the user clicks on an item in the list, a new activity with the contents of the item selected should be displayed ; use descendant and ancestral navigation pattern between the activity with list of books and activity displaying information for a book.
4. There should be a floating action button to add new books.
5. On the activity that displays details for a book, allow users to update the book details or delete the book; the user action (edit or delete) should be reflected in the database.

Solution PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

package;

import java.text.DecimalFormat;

/**
* RoadEdge.java: Edge child class for use with our MapGraph class, as it has extra qualities compared to an edge
*
* Class Invariant:
*
* @version       1.0
**/
public class RoadEdge extends Edge {

    //variables, used to multiply/affect weight

    //number of traffic lights on a road
    private double trafficLights;
    //time of day
    private double timeOfDay;
    //weather conditions
    private int weatherConditions; //this will be 0-3 for clear weather to rainy to heavily rainy to hailing


    private boolean freeway;

//constructors
    RoadEdge(int source, int dest, double pWeight, double trafficLights, boolean freeway){
       this.source = source;
       this.dest = dest;
       this.weight = pWeight;
       this.trafficLights = trafficLights;
       this.freeway = freeway;
    }
    // Constructs a RoadEdge from source to dest. Sets the weight to 1.0
    public RoadEdge(int source, int dest) {
       super(source, dest);
    }
    // Constructs a RoadEdge from source to dest. Sets the weight to passed value with modifiers/variables RoadEdge has
    public RoadEdge(int source, int dest, double pWeight){
       this.source = source;
       this.dest = dest;

       this.weight = pWeight; //* (trafficLights/3); //we will see how this looks, can tweak

    }
//toString
    @Override
    public String toString() { return "[" + source + ", " + dest + ", W: " + new DecimalFormat("###.###").format(weight) + ", lights: " + trafficLights + ", is freeway: " + freeway + "]"; }
//equals
    @Override
    public boolean equals(Object o) {                      //RoadEdges are equal if source, destination, and weight are equal
       if(o == null || getClass() != o.getClass()) {
            return false;
       }
       RoadEdge other = (RoadEdge)o;
       return this.source == other.source && this.dest == other.dest && this.weight == other.weight;
    }
//getters
    public double getTrafficLights() {
       return trafficLights;
    }
    public double getTimeOfDay() { return timeOfDay; }
    public int getWeatherConditions() { return weatherConditions; }
    public boolean isFreeway() {
       return freeway;
    }
//setters
    public void setTrafficLights(double trafficLights) {
       this.trafficLights = trafficLights;
    }

    public void setTimeAndWeather(double timeOfDay, int weatherConditions) {
       this.timeOfDay = timeOfDay;

       switch (weatherConditions){
            case -1:
                System.out.println("There was an error in the weather conditions");    //perhaps throw an exception here?
                return;
            case 0:
                break;
            case 1:
                weight *= 1.325;
                break;
            case 2:
                weight *= 1.5077;
                break;
            case 3:
                weight*= 1.78;
                break;
            default:
                break;
       }...
$50.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available App Development Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats