You are on page 1of 9

HACETTEPE UNIVERSITY

Computer Science and Engineering Department

BİL138 PROGRAMMING LABORATORY


2008/2009 SPRING
EXPERIMENT 1

➢ Name and Surname Muhammet GUNEY


➢ Identity Number 20521487
➢ Course Bil 137
➢ Experiment 1
➢ Subject Inheritance, Access Modifiers Usage
,Method
Overloading
➢ Submission Date 13.03.2009
➢ Due Date 20.03.2009
➢ Advisors Dr. Ebru Sezer, R.A. Önder Keskin
➢ e-mail samet@guney.com
➢ Platform /Editor WINDOWS Vista / Eclipse
➢ Main Program MainClass.java
1. Software Catologue Information

Programmer Muhammet GÜNEY


Programming Language Java
Operating System Windows Vista
Main Program MainClass.java

2. Software Using Documentation

2.1.Software Usage

This program runs to show menu and want user to choose user’s choice.

User can use “A , R, S, L, C, E” to choose what user want to do.

✔ If choice is ‘A’ , Program will run “Add a new book” .

Program ask user to give ISBN , name of Book , name of Author .


✔ İf choice is ‘L’ , Program will run “List” .

Program will list . List will be ordered by use name of book.


For example if user give followings items , program will list them like
*(LİST Window)

Program will put in order each entry by use name of book


..

✔ İf choice is ‘S’ , Program will run “Search for a book” .

Program will ask user to give string .After , will look entry is exist or
not.İf there is
a record ,show other attributes else entry not found.

✔ İf choice is ‘R’ , Program will run “Removing a book”

Firstly, User enter isbn number of the book and then book details (name,
author) will be
printed. After that program will ask the user to confirm deletion.

✔ İf choice is “C‘’ , Program will run “Book Count”

Write how much book are there on list.


2.2. Provided Possibilities

Programe will be end when user choice “E” else programe will show menu.

2.3.Error Messages

1.Wrong Choice---- Error! Try again pleas...


2.Same ISBN ---- This entry added before
3.No found name--- Entry not found

3. Software Design Notes


3.1. Desctiption of the program
3.1.1.Problem
Staff of book ıtem need a program to compile .User will get command to which operations
will do.program will perform followings items.

Show Menu
Get choice
Run choosen
Show Menu until user choice “E”

3.1.2.Solution
My programe have 4 class. (MainClass,Menu,Book,Functions) This
classes will be helpful to solve this problem. We will use object oriented
to call class methods. Program
will start with MainClass thats have main metods.

MainClass
have 1 method
public static void main(String [] args )

main method
create a object to call menu class’s method
Menu menu = nev Menu();
Menu class
Have menu method and it will show menu until user choice “E”.
Create a object to call Functions Class’s methods

Functions class
private Scanner sc = new Scanner(System.in);
private Book book[]=new Book[100];

Add method
Get ISBN,nameof book , name of author from user and save
them by use
book object.before save , look ISBN is added before. For this , use
controlISBN method.

Remove method
Get ISBN from user to control for exist or not. İf there is a enty
ask user to delete or not. İfuser get “yes” , delete it.

This method will use removeEntry method to delete.

searchName method
Get string from user and search this string at name of book.İf
there is string at name of book , write it to show user.
I used to String.matches(string) for find string.

orderList method
ı kept name of boks at a String array and ı used
Arrays.sort(String array[]) to order .

count method
show how much are there at system.

Book class
private int isbn;//to object
private String name;//to object
private String author;//to object
public static int bookCount=0;//keep to count of boks // TO CLASS
we will keep specialies of books at here.
I hava a constructor.
public Book(String name ,String author ,int isbn)
{
this.name=name;
this.author=author;
this.isbn=isbn;
bookCount++;
}
When user add a new book , bookcount will raise.
3.2.Main Data Structe
SYSTEM

This figure is basicly explaning the project


3.3.Algorithm
1. Start with main method at MainClass
1.1.Create new Menu name of the “menu”
1.2.Run menu
1.2.1.Show menu
1.2.2.Run menu.choice to get choice
1.2.3.Create new Functions name of the “fc”
1.2.4.İf choice is “A” ,”a” , run fc.add
1.2.4.1.Get ısbn
1.2.4.2.Control ısbn
1.2.4.3.İf ısbn isnt exist , get name and author to add
1.2.4.4.Use new Bookname of the “book” to add new book
1.2.5.İf choice is “R” ,”r” , run fc.remove
1.2.5.1.Get ISBN to control it with fc.controlISBN
1.2.5.2.İf there is a entry , show name and author
1.2.5.3.Ask user to delte entry or not
1.2.5.4.İf user get “yes” , remove entry by use
fc.removeEntry
1.2.6.İf choice is “S” ,”s” , run fc.searchName
1.2.6.1.Get string
1.2.6.2.Look name to match string by use
string.match(string)
1.2.6.3.İf there is a entry or more , show all at window
1.2.7.İf choice is “L” ,”l” , run fc.orderList
1.2.7.1.Create a string array and fill in it with name of book
,author ,ISBN
1.2.7.2.Order array by use Arrays.sort(array[])
1.2.7.3.Write array[]
fc.count
1.2.8.İf choice is “C” ,”c” , run
1.2.8.1.Show count by use Book.bookCount
1.2.9.İf choice is “E” ,”e”
1.2.9.1.Write “Thanks you to use this programe”
1.2.10.else
1.2.10.1.Write “Error message!!” and show menu again

Book
private int isbn;//to object
private String name;//to object
private String author;//to object
public static int bookCount=0;//keep to count of books

public Book(String name ,String author ,int isbn)


{
this.name=name;
this.author=author;
this.isbn=isbn;
bookCount++;
}

public void setIsbn(int isbn) {


this.isbn = isbn;
}

public void setName(String name) {


this.name = name;
}

public void setAuthor(String author) {


this.author = author;
}

public int getIsbn() {


return isbn;
}

public String getName() {


return name;
}

public String getAuthor() {


return author;
}