Lab 1(NEW)

Due January 28

Sample Reader code: SampleReaderCode


The overall goal of this project is the development of a program for retrieving Bible verses from a set of sequential files containing the Bible text. The program will eventually use a Web based user interface. The user will supply the book, chapter, and verse to the program, and the program will display the verse.

This first handout only specifies the first part, the writing of a program that reads a Bible book, parsing it into verse and reference objects, and displaying a selected verse. This code will then be integrated into the complete project. Thus with this program will create a bible object, and allow you to retrieve verses. The starting code can be found here: SampleReaderCode.


You will implement the objects below, and then write a simple “wrapper” to test them. The wrapper is a command line program that has three or four parameters as follow:

skon@tarus% bible_lookup 8 4 11
11 And all the people that were in the gate, and the elders, said, We are
witnesses. The LORD make the woman that is come into thine house like Rachel
and like Leah, which two did build the house of Israel: and do thou worthily
in Ephratah, and be famous in Bethlehem:
skon@tarus% bible_lookup 63 1 7 4
2 JOHN 1
7 For many deceivers are entered into the world, who confess not that Jesus
Christ is come in the flesh. This is a deceiver and an antichrist.
8 Look to yourselves, that we lose not those things which we have wrought, but
that we receive a full reward.
9 Whosoever transgresseth, and abideth not in the doctrine of Christ, hath not
God. He that abideth in the doctrine of Christ, he hath both the Father and
the Son.
10 If there come any unto you, and bring not this doctrine, receive him not into your house, neither bid him God speed:
skon@tarus% bible_lookup 69 3 5 3
Error – no such book
skon@tarus% bible_lookup 1 77 3 5
Error – No such chapter 77 in Genesis
skon@tarus% bible_lookup 1 50 82 5
Error – No such verse 82 in Genesis 50
skon@tarus% bible_lookup 1 50
Error – verse number is missing

Note the output format … Print out the book name and chapter, then each verse number before each verse that is printed. This will require you to modify the sample code I gave you appropriately.


This project has the following learning goals:

  1. Sequential file search and retrieval

  2. C++ object oriented file handling

The Bible text is one complete file with the entire bible.

The file is organized as a sequential file, with variable length records, one verse in each record. Each record has the following format:

  1. 1-2 character book number
  2. Colon
  3. 1-3 character chapter number
  4. Colon
  5. 1-3 character verse number
  6. 1 space
  7. Remainder of record is verse text.
Example verse records:

1:1:19 And the evening and the morning were the fourth day.

49:1:23 Which is his body, the fulness of him that filleth all in all.

50:4:4 Rejoice in the Lord alway: and again I say, Rejoice.

The records are ordered in verse order.

The file may be found in "/home/class/csc3004/Bible/kjv-complete". Do not copy this into your own account! Open and read the file directly in the class directory in your program.

A sample program is available in “"/home/class/csc3004/biblereaderdemo” which, when prompted for a bible book number, displays a complete book. Create a new directory, and copy over the contents of the directory, and use “make” to build the program. Then try it out!


Retrieve the code in “"/home/class/csc3004/sample_reader”. This includes the file “Makefile”, “sample_reader.cpp”, and “sample_reader.h”. This code simply reads the specified verse into a string. Your task is to upgrade this code so it uses at least three objects, a Bible object, a verse object and a reference object.

This code is compiled using a “Makefile”. A Makefile is simply a set of commands that tells how to make a certain project. This makes building possibly complex systems easy. All you have to do is type “make” in the directory with the make file and source files, and the make program will use the Makefile to build the program. Then you can run the program by typing the name of the program followed by the name of the book file you want to display:

skon@tarus% ./sample_reader 18
18:1:1 There was a man in the land of Uz, whose name was Job; and that man was perfect and upright, and one that feared God, and eschewed evil.
18:1:2 And there were born unto him seven sons and three daughters.
18:1:3 ...

You will use command line parsing to parse either 3 or 4 parameters to read in a book number, a chapter number, a verse number, and finally an optional number of verses. Note that the number of verses may span chapters, but you do not have to span books.

Note that the file includes book numbers, but this project requires that you convert the book number to a book name in the output. This will require a method to convert from a book number to a book name string.

Some of the classes you could use are shown below. You must support at least these features, but may add more as needed. Also - you could have the verse text be stored in dynamic memory, but if you do that you will need a destructor.

Your goal is to create a new solution with 4 CPP files:

  1. BibleReader .cpp, BibleReader .h
  2. Bible.cpp, Bible.h
  3. Verse.cpp, Verse.h
  4. Ref.cpp. Ref.h
The new solution will start by creating an object of class "Bible", which has a constructor to which you pass a file name string indicating where the Bible resides in the file system.


Header Guards See this:

Sample Start Code

The beginnings of ALL these files, including the makefile, are in the class directory at in /home/class/csc3004/bibleclassdemo. Copy this to your folder to start with.

You can also look at the code online Here

What to turn in on Moodle

Turn in your code listing and the result of several runs (captured). Show both cases that work, as well as cases where the verse or chapter searched for does not exist. Please structure and document your code appropriately. Plan to demo your solution in lab. (Feb. 4)

Topic revision: r2 - 2016-02-09 - BenjaminKindle
This site is powered by the TWiki collaboration platformCopyright &© by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback