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

I need help to understand how this all works. The teacher emailed me but I\'m ha

ID: 3807001 • Letter: I

Question

I need help to understand how this all works. The teacher emailed me but I'm having trouble how each class uses eachother and why. I might drop the class. But i want to see how this should look like so when I take another class with same learning outcomes I can understand what this data structure should represent.

Binary Search Tree

What to do: Write four classes: Bookstore, BSTree.java, BNode.java, and Book.java. If you created any extra classes for this assignment (such as the book exception, the node exception or the tree exception).

Comments   Please comment all your classes and methods with a brief description of what each method does.

Program requirements and structure

Your tree should store Book objects into a binary search tree. In order to do this you should put the Book object into a BNode and add the BNode to the BSTree object. The classes and methods described below are there to give you an idea of what is required from you. You are free to organize your project any way you want as long as you have AT LEAST these four required classes, but do not forget that you need to validate everything, thus you will need to have exception classes.

·         Bookstore.java, which is your driver class

·         BSTree.java, which will implement all the binary tree functionality

·         BNode.java, (tree node) which will create nodes for your tree.

·         Book.java, this class will create books that will go inside the node.

ISBN number should be from 101 to 999 inclusive

Book Title mustbe at least 3 non-blank characters long

This will be a binary search tree formed with nodes that contain book-objects. You will be simulating a bookstore. You may purchase books which will be added to the BSTree or you may have customers purchase books from you. Your BSTree structure should function as your database.

ton String message message Schmessage Remove redd find in f C f and found isbn nt string title int get lsbn tmry get title (int) VOM set lskn (Strin tuod set Title BNode BNode r o at BNode left child Node right Chilel B. void add Book Book book void remove isbn BNode get beft Child vald set Left Child Krvode) re curs (ve taker root as void setR ight Child (BNoclo) String to string Driver Bookstore has a menu reads info book BNo cle did book Tree dd Brodu to 5S

Explanation / Answer

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

BNode.java

package WordNode;

public class BNode {

   Book book;

   BNode leftChild;
   BNode rightChild;


   public BNode getLeftChild() {
       return leftChild;
   }
   public void setLeftChild(BNode leftChild) {
       this.leftChild = leftChild;
   }
   public BNode getRightChild() {
       return rightChild;
   }
   public void setRightChild(BNode rightChild) {
       this.rightChild = rightChild;
   }
   @Override
   public String toString() {
       return "BNode [book=" + book + ", leftChild=" + leftChild + ", rightChild="
               + rightChild + "]";
   }

}

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

BSTree.java

package WordNode;

public class BSTree {

   BNode root;


   void add(BNode bNode){

       System.out.println("Add the Book");

   }


   boolean remove(int isbn){

       System.out.println("Remove the Book with that Number");
       return false;
   }


   public int myRecursiveMethod()
   {
       int root = myRecursiveMethod();
       return root;
   }

   int printInOrder(int root){
       System.out.println(root);

       root--;
       if(root == 0){

           return 0;
       }
       return myRecursiveMethod();

   }
}

**********

BookException.java

package WordNode;

public class BookException extends Exception {
  
  
   String message;

   public String getMessage() {
       return message;
   }

   public void setMessage(String message) {
       this.message = message;
   }

  

}

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

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

BookStore.java

package WordNode;

public class BookStore extends BSTree{

   public BookStore() {
       // TODO Auto-generated constructor stub
   }


   void readBookInfo(Book book){
       System.out.println("Read the Book taking book as the parameter");

   }


   void buildBook(Book book){

       System.out.println("Build the book");

   }

   void addBookintoBNode(Book book){

       book.setTitle("The Greatest MindSet");
       book.setIsbn(1234);


   }


   void addBNodetoBSTree(BSTree bstree){

       BNode bNode = null;
       bstree.add(bNode);

   }

   public static void main(String[] args) {

       Book book=new Book();
       BSTree bstree=new BSTree();

       book.getIsbn();

       if(bstree.remove(1234)== false){
           System.out.println("Delete that Book");
       }else{
           System.out.println("Book is available");
       }


   }

}

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

Output:

Remove the Book with that Number
Delete that Book

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