Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Question : Write a Server-Client JAVA program in which an ONLINE Shopping System

ID: 662290 • Letter: Q

Question

Question: Write a Server-Client JAVA program in which an ONLINE Shopping System running on the server and preloaded with a group of books created using data from a text file "ReadingMatterialInputFile.txt". The client sends a UDP message (the customers request) to the server, which is waiting to receive packets at a well-known IP address and UDP port number. The customer request contains the category and the title of the book they wish to purchase.

The protocol for this problem runs on top of the Internet Protocol (IP) and the User Datagram Protocol, UDP.

The server, may or may, not implement the GUI. The server will validate the message received from a customer, that is, checks that there is a category and title of the book in the message. The server runs the customers request and then sends back a message with the title and isbn details of the first book in its internal listing that is able to satisfy the customer request.


The client's initial message might be lost in the network. Therefore, if a response is not received in a certain time (10 seconds), the client times out and retransmits the request message; this may be repeated several times before the client finally gives up and declares failure.

Here are the Text file & class files which are needed to answer the question. Create two class for Server and Client. Please include a screenshot of the program:

***********************************************************************************************

Preload books information from this text file:
*********************************************************

ReadingMatterialInputFile.txt
===========================

BOOK
TITLE: "A Concise History of Australia"
ISBN: "9780521601016"
PRICE: 29.99
AUTHOR: "Stuart Macintyre"

BOOK
TITLE: "The Bloxworth Blue"
ISBN: "9780060213435"
PRICE: 12.95
AUTHOR: "William Corlett"

BOOK
TITLE: "A Stranger Here"
ISBN: "9780060214395"
PRICE: 13.89
AUTHOR: "Thelma Hatch Wyss"

BOOK
TITLE: "My Visit to the Aquarium"
ISBN: "9780060214586"
PRICE: 16.99
AUTHOR: "Aliki Aliki(Illustrator)"

MAGAZINE
TITLE: "Time"
ISBN: "9781933405162"
PRICE: 4.95
EDITOR: "Stengel, Richard"

MAGAZINE
TITLE: "Harper's Magazine"
ISBN: "9781580603041"
PRICE: 6.95
EDITOR: "Rosenbush, Ellen"

MAGAZINE
TITLE: "The People"
ISBN: "9781603208055"
PRICE: 14.40
EDITOR: "Hackett, Larry"

MAGAZINE
TITLE: "The Southern Living"
ISBN: "9780848742980"
PRICE: 45.78
EDITOR: "Evans , Sid"

TEXTBOOK
TITLE: "Java: How to Program"
ISBN:"9780131364837"
PRICE: 123
AUTHOR: "Deitel, Paul", "Deitel, Harvey"
ANSWERS: true

TEXTBOOK
TITLE: "EEC Law"
ISBN:"9781854312242"
PRICE: 79.99
AUTHOR: "Steiner, Josephine"
ANSWERS: true

TEXTBOOK
TITLE: "Basic Nursing"
ISBN:"9781605477725"
PRICE: 167.67
AUTHOR: "Rosdahl, Caroline Bunker", "Kowalski, Mary T"
ANSWERS: true

TEXTBOOK
TITLE: "Information Technology Project Management"
ISBN:"9781285847092"
PRICE: 214.77
AUTHOR: "Schwalbe, Kathy"
ANSWERS: true

NOVEL
TITLE: "Harry Potter and the Sorcerer's Stone"
ISBN: "059035342X"
PRICE: 10.99
AUTHOR: "Rowling, J. K."
CHARACTERS: "Harry Potter", "Ron Weasly", "Hermione Granger"

NOVEL
TITLE: "Luckiest Girl Alive"
ISBN: "1476789630"
PRICE: 32.75
AUTHOR: "Knoll, Jessica"
CHARACTERS: "Ani FaNelli"

NOVEL
TITLE: "All the Light We Cannot See"
ISBN: "1476746583"
PRICE: 27.00
AUTHOR: "Doerr, Anthony"
CHARACTERS: "Marie-Laure", "Werner"

NOVEL
TITLE: "Liberty A Novel of Lake Wobegon"
ISBN: "057124582X"
PRICE: 6.45
AUTHOR: "Keillor, Garrison"
CHARACTERS: "Clint Bunsen", "Miss Liberty", "Hermione Granger"
======================================================

Class files required for category of the books.

=========================================

//ReadingMatter has three instance variables: title (type String),
//ISBN (type String of 13 characters)
//and price (type double).

public class ReadingMatter {
   // instance variables
   String title;
   String ISBN;
   double price;

   // constructor
   ReadingMatter(String title, String ISBN, double price) {
       this.title = title;
       this.ISBN = ISBN;
       this.price = price;
   }

   // getter and setters
   public String getTitle() {
       return title;
   }

   public void setTitle(String title) {
       this.title = title;
   }

   public String getISBN() {
       return ISBN;
   }

   public void setISBN(String iSBN) {
       ISBN = iSBN;
   }

   public double getPrice() {
       return price;
   }

   public void setPrice(double price) {
       this.price = price;
   }

   //toString( ) method to return a
   //description of the reading matter.
   public String toString() {
       return "Title:" + title + " " + "ISBN" + ISBN + " " + "price:"
               + price;
   }
}


==========================

//Book includes an extra instance variable: author (type ArrayList)
//with get and set methods for it. There may be more than one author
//so allow their names to be stored in an ArrayList. Also override toString( )
//method to include Books author details.

import java.util.ArrayList;

public class Book extends ReadingMatter {
   // instance variable
   ArrayList author;
  
   //constructor
   Book(String title, String ISBN, double price, ArrayList author) {
       super(title, ISBN, price);
       this.author = author;
   }

   //getter and setters
   public ArrayList getAuthor() {
       return author;
   }

   public void setAuthor(ArrayList author) {
       this.author = author;
   }

   //to String
   @Override
   public String toString() {
       return super.toString()+" List of authors:"+author;
   }

}


======================================

//Magazine includes an extra instance variable: editor (type String) with
//get and set methods for it. Also override toString( ) and content( )
//methods to include Magazines editor details.

public class Magazine extends ReadingMatter {
   // instance variable
   String editor;

   // constructor
   Magazine(String title, String ISBN, double price, String editor) {
       super(title, ISBN, price);
       this.editor = editor;
   }

   //getter and setters
   public String getEditor() {
       return editor;
   }

   public void setEditor(String editor) {
       this.editor = editor;
   }

   //toString method
   @Override
   public String toString() {
       return super.toString() + " Magazine editor:" + editor;
   }
}


============================================

//Novel includes extra instance variable characters
//(type ArrayList) with get and set methods for it. Also override toString( ) method to include all

import java.util.ArrayList;

public class Novel extends Book{
  
   ArrayList characters;
   Novel(String title, String ISBN, double price, ArrayList author,ArrayList characters) {
       super(title, ISBN, price, author);
       this.characters=characters;
   }

  

   public ArrayList getCharacters() {
       return characters;
   }

   public void setCharacters(ArrayList characters) {
       this.characters = characters;
   }
   @Override
   public String toString() {
       return super.toString()+" Novel-characters:"+characters;
   }
}


=============================================

//TextBook includes extra instance variable answers (type boolean)
//with get and set methods for it. Also override toString( )
//method to include TextBook details

import java.util.ArrayList;

public class TextBook extends Book {
   boolean answers;

   TextBook(String title, String ISBN, double price, ArrayList author,
           boolean answers) {
       super(title, ISBN, price, author);
       this.answers = answers;
   }

   public boolean isAnswers() {
       return answers;
   }

   public void setAnswers(boolean answers) {
       this.answers = answers;
   }
  
   @Override
   public String toString() {
       return super.toString()+" Textbook answers:"+answers;
   }

}


===========================================

Explanation / Answer

public class ReadingMatter {

            String title;

String ISBN;

double price;

        ReadingMatter(String title,String ISBN,double price) {

                     this.title = title;

                     this.ISBN = ISBN;

                     this.price = price;

}

public String getTitle() {

return title;

}

public void setTitle(String title) {

           this.title = title;

}

public String getISBN() {

return ISBN;

}

public void setISBN(String SBN)

{

   ISBN = iSBN;

}

public double getPrice() {

return price;

}

public void setPrice(double price) {

this.price = price;

}

public String toString() {

               return "Title:" + title + " + " ISBN " + ISBN + " " + price:"   +price;

     }

}

import java.util.ArrayList;

public class Book extends ReadingMatter {

ArrayList author;

private ArrayList<Book> allBooks = new ArrayList<Book>;

Book(String title,String ISBN,double price,ArrayList author) {

      Super(title,ISBN,price);

      this.author = author;

}

public ArrayList getAuthor() {

return author;

}

public void setAuthor(ArrayList author) {

this.author = author;

}

public void addBooks() {

    allBooks.add(new Book(29.99,"A Concise History of Australia",Stuart Macintyre","9780521601016"));

}

public void addBooks() {

       allBooks.add(new Book(12.95,"The Bloxworth Blue","William Corlett","9780060213435"));

}

public void addBooks()   {

    allBooks.add(new Book(13.89,"A Stranger Here","Thelma Hatch Wyss","9780060214395"));

}

public void addBooks() {

      allBooks.add(new Book(16.99,"My Visit to the Aquarium","Aliki Aliki(Illustrator)","9780060214586"));

}

public String toString() {

return super.toString() +" List of authors:"+author;

}

}

public class Magazine extends ReadingMatter {

Magazine(String Title;String ISBN;double price,String editor) {

super(title,ISBN,price);

this.editor = editor;

}

public String getEditor() {

return editor;

}

public void setEditor(String editor) {

this.editor = editor;

}

public void addMagazines() {

allmagazine.add(new Magazine(4.95,"Time","Stengel,Richard","9781933405162"));

}

public void addMagazines() {

allBooks.add(new Book(6.95,"Harper's Magazine","Rosenbush,Ellen","9781580603041"));

}

public void addMagazines() {

allMagaziness.add(new magazine(14.40,"The People","Hackett,Larry","9781603208055"));

public void addMagazine() {

allMagazines.add(new Magazine(45.78,"The Southern Living","Evans,Sid","9780848742980"));

}

public String toString() {

return super.toString() +" Magazine editor:" + editor;

}

}

import java.util.ArrayList;

public class TextBook extends Book {

boolean answers;

TextBook(String title,String ISBN,double price,ArrayList author,boolean answers){

super(title,ISBN,price,author);

this.answers = answers;

}

public boolean isAnswers() {

    return answers;

public void setAnswers(boolean answers){

    this.answers = answers;

public void addTextBooks() {

allTextBooks.add(new TextBook(123,"Java: How to Program","Deitel,Paul","Deitel,Harvey","978013164837","true"));

}

public void addTextBooks() {

    allTextBooks.add(new TextBook(79.99,"EEC Law","Steiner,Josephine","9781854312242","true"));

}

public void addTextbooks() {

all TextBooks.add(new TextBook(167.67,"Basic Nursing","Rosdahl,Caroline Bunker","Kowalski,Mary T","9781605477725","True"));

}

public void addtextBooks() {

all Textbooks.add(new TextBook(214.77,"Information Technology Project Management","Schwalbe,Kathy","9781285847092","true"));

}

public String toString() {

return super.toString()+" Textbook answers:" +answers;

}

}

import java.util.ArrayList;

public class Novel extends Book{

ArrayList characters;

Novel(String title,String ISBN,double price,ArrayList author,ArrayList characters) {

super(title,ISBN,price,author);

this.characters = characters;

}

public ArrayList getCharacters() {

return characters;

}

public void setCharacters(ArrayList characters){

this.characters = characters;

}

public void addNovel() {

allNovels.add(new Novel(10.99,"Harry Potter and the Sorcerer,s Stone,"Rowling,J.K.","Harry Potter","Ron Weasly","Hermione Granger","059035342X"));

}

public void addNovel() {

    allNovels.add(new Novel(32.75,"Luckiest Girl Alive","Knoll,Jessica","Ani FaNelli","1476789630"));

}

public void addNovel() {

     allNovels.add(new Novel(27.00,"All the Light We cannot","Doerr,Anthony","Marie-Laure","1476746583"));

}

public void addNovel() {

   allNovels.add(new Novel(6.45,"Liberty A Novel of Lake Wobegon","Keillor,Garrison","Clint Bunsen","Miss Liberty","Hermione Granger","057124582X"));

}

public String toString() {

return super.toString()+" Novel-characters:"+characters;

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote