Question

JAVA: OOP Bible Main.java Overview Design a set of OOP classes to model a bible app....

JAVA:

OOP Bible

Main.java

Overview

Design a set of OOP classes to model a bible app.

Details

Bible

  • ArrayList<Book> books
  • String translation
  • randomVerse()
  • search(String s)

Book

  • ArrayList<Chapter> chapters
  • BookType type
  • String author
  • TestatmentType testament

BookType - enum

  • Law, History, Poetry, MajorProphets, MinorProphets, Gospel, PaulineEpistles, GeneralEpistles, Prophecy.

TestamentType - enum

  • OldTestament, NewTestament

Chapter

  • ArrayList<Verse> verses
  • int number
  • String title
  • toString()

Verse

  • String text
  • int number
  • boolean isHighlighted
  • highlight()
  • unhighlight()
  • comment(String comment)
  • ArrayList<String> comments
  • toString()
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Here are all the java and enum classes

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

import java.util.ArrayList;

public class Verse {

    private String text;
    private int number;
    private boolean isHighlighted;
    private ArrayList<String> comments;

    public Verse(String text, int number, boolean isHighlihgted) {
        this.text = text;
        this.number = number;
        this.isHighlighted = isHighlihgted;
    }

    public void highlight() {
        this.isHighlighted = true;
    }

    public void unhighlight() {
        this.isHighlighted = false;
    }

    public void comment(String comment) {
        comments.add(comment);
    }

    @Override
    public String toString() {
        String desc = text + ", " + number + ", " + (isHighlighted ? "highlighted" : "not highlighted, Comments: ");
        for (String comment : comments) {
            desc += comment + " ";
        }
        return desc;
    }
}

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

import java.util.ArrayList;

public class Chapter {

    private ArrayList<Verse> verses;
    private int number;
    private String title;

    public Chapter(int number, String title) {
        this.number = number;
        this.title = title;
        verses = new ArrayList<>();
    }

    public void addVerse(Verse v) {
        verses.add(v);
    }

    @Override
    public String toString() {
        String desc = "Number: " + number + ", Title: " + title;
        desc += ", Verses: ";
        for (Verse v : verses) {
            desc += v;
        }
        return desc;
    }

    public ArrayList<Verse> getVerses() {
        return verses;
    }
}

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

public enum TestamentType {

    OldTestament, NewTestament;
}

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

public enum BookType {

    Law, History, Poetry, MajorProphets,
    MinorProphets, Gospel, PaulineEpistles,
    GeneralEpistles, Prophecy;

}

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

import java.util.ArrayList;

public class Book {

    private ArrayList<Chapter> chapters;
    private BookType type;
    private String author;
    private TestamentType testament;

    public Book(BookType type, String author, TestamentType testament) {
        this.type = type;
        this.author = author;
        this.testament = testament;
        chapters = new ArrayList<>();
    }

    public void addChapter(Chapter c) {
        chapters.add(c);
    }

    public ArrayList<Chapter> getChapters() {
        return chapters;
    }
}

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

import java.util.Random;
import java.util.ArrayList;

public class Bible {

    private ArrayList<Book> books;
    private String translation;

    public Bible(String translation) {
        this.translation = translation;
        books = new ArrayList<>();
    }

    public void addBook(Book b) {
        books.add(b);
    }

    public Verse randomVerse() {

        Random random = new Random();
        Book randomBook = books.get(random.nextInt(books.size()));
        ArrayList<Chapter> chapters = randomBook.getChapters();
        Chapter randomChapter = chapters.get(random.nextInt(chapters.size()));
        ArrayList<Verse> verses = randomChapter.getVerses();
        Verse randomVerse = verses.get(random.nextInt(verses.size()));
        return randomVerse;

    }
}

===============================================x=============================================

Add a comment
Know the answer?
Add Answer to:
JAVA: OOP Bible Main.java Overview Design a set of OOP classes to model a bible app....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT