We have been working very hard since 2009 to facilitate in learning Read More. We can't keep up without your support. Donate.

Assignment No. 01 Fall 2015 CS506- Web Design and Development Total Marks: 20 Due Date: 24/11/2015

Assignment No. 01

 Fall 2015
CS506- Web Design and Development

Total Marks: 20

Due Date: 24/11/2015

Please read the following instructions carefully before solving & submitting assignment:

It should be clear that your assignment will not get any credit  if:

  • The assignment is submitted after due date.
  • The submitted assignment does not open or file corrupt.
  • The assignment is fully or partially copied from (other student or ditto copy from handouts or internet).
  • Student ID is not mentioned in the assignment File or name of file is other than student ID.
  • The assignment is not submitted in .java format.

 

Uploading instructions

Your submission must include:

 

  1. All the source code (.java files) and other necessary files to compile and run your program.
  2. You have to make one java file and Upload it on VULMS.

 

Note: Use Notepad or Notepad++ for coding and JDK package for java source code compilation and running (A guideline document on JDK installation and configuration is given in course download section)

Objective

The objective of this assignment is to

  • Give you some practice exercise of Classes and Objects. And how to compile and run java programs.
  • Develop GUI (Graphical User Interface) in java
  • Understand the concept of Collections in java

 

 

Problem Statement:                                                        

You are required to write a java program which contains only two classes named as “BookInfo” and “BookMgtSys”.

 

BookInfo class must have the following data members:

  • ISBN
  • Book Name
  • Author Name
  • Total Books

When you will add book then it will increment variable Total Books and decrement when you will delete book.

 

BookInfo class must have the following member methods:

  • Default constructor
  • Parameterized constructor
  • addbook () 
  • searchBook ()
  • deleteBook ()

 

BookMgtSys is a public driver class that contains the main() method. The name of you file should be BookMgtSys as it is a public class in your program.                                                                             

Detailed Description:

Default constructor: The default constructor will create an ArrayList.

Parameterized constructor: It should take three String parameters named as (ISBN, Book Name, and Author Name) and initializes the data members values with the passed parameters.

addBook(): This method will ask the user to enter ISBN, Book name and Author name and then add the book in 

ArrayList and increment the Total Book variable. After successful adding the book, A message box should be displayed containing Book information.

searchBook(): This method takes one parameter which is book name and search the book name in the ArrayList. If search is found then display the Book information otherwise display message that Book not found.

deleteBook(): This method takes one parameter which is book name and delete the book from the ArrayList and then decrement the Total Book variable. 

 

Use JOptionPane for input and output data.

 

Sample Output:

Within main() method, the following message box should be displayed.

 

If user presses 1 then it should ask the user to add further information

Deadline

Your assignment must be uploaded/submitted at or before 24th Nov, 2015.

 

 

For any query about the assignment, contact at cs506@vu.edu.pk

GOOD LUCK

Views: 17111

Attachments:

Replies to This Discussion

how lengthy code....

Take Ideas from each other and solve yourself.......Assignments are not for getting solutions only....they are NITRO for your study to boost up your thinking capabilities....If you present a self made Solution ....even if it is wrong....u will get some marks for attempt.....

kindly upload the full solution pleaseeeeeeeeeeee

ali khawaja brother please share your email address. I HAVE SOME PROBLEMS IN THE ASSIGNMENT WHICH I NEED TO DISCUSS FOR CORRECTION. I THINK WE SHOULD MAKE A SKYPE GROUP?

Solution ni mil rha yar net sa b is ka 

lecture no 6 page (66-69)

idea solution for assignmnt

correct slution nhi ha ye.

ye submit kese krwani dono classes aik he file me likhni hein ya aleda aleda

Hello Guys,

here is the solution, please don't just copy and paste. Make some modifications in it. If you can't then at least

  • type yourself
  • change classes names and other variables names

 

BookInfo.java

import javax.swing.*;
import java.util.*;

public class BookInfo{
String isbn;
String name;
String author;

//default Constructor
public BookInfo(){
isbn = "101";
name = "Java, How to Program";
author = "Dietel Dietel";
}

//parametrized constructor
public BookInfo(String i, String n, String a){
isbn = i;
name = n;
author = a;
}

public void printBookInfo(){
JOptionPane.showMessageDialog(null, "ISBN " + isbn + " Name " + " Author " + author);
}

}

Books.java

import javax.swing.*;
import java.util.*;

public class Books{

ArrayList book = new ArrayList();

//add a new book to Array List
public void addBook(){
String isbn = JOptionPane.showInputDialog("Enter the ISBN");
String name = JOptionPane.showInputDialog("Enter then Book Name");
String author = JOptionPane.showInputDialog("Enter the Author Name");

BookInfo b = new BookInfo(isbn, name, author);
book.add(b);
}

//search a book in Array List
public void searchBook(String n){
for(int i = 0; i < book.size(); i++){
BookInfo b = (BookInfo)book.get(i);

//checking for the book name
if(n.equals(b.name)){
b.printBookInfo();
}
}//end for loop
}

//delete a book in Array List
public void deleteBook(String n){
for(int i = 0; i < book.size(); i++){
BookInfo b = (BookInfo)book.get(i);

//comparing all books with user string
if(n.equals(b.name)){
book.remove(i);
}
}
}

}

Execute.java

import javax.swing.*;
import java.util.*;

public class Execute{
public static void main(String args[]){
Books b = new Books();

while(true){
String userInput = JOptionPane.showInputDialog("Enter 1 to Add Book\nEnter 2 to Search Book\nEnter 3 to Search Book\nEnter 4 to Exit System");
int i = Integer.parseInt(userInput);

switch(i){
case '1':
b.addBook();
break;

case '2':
String s = JOptionPane.showInputDialog("Enter Book name to search");
b.searchBook(s);
break;

case '3':
String s = JOptionPane.showInputDialog("Enter Book name to delete");
b.deleteBook(s);
break;

case '4':
System.exit(0);
}
}

}

}

NOTE: There will be some warnings like recompile it with -xh...... But it's working!

In case of any problem, ask me

ye sara code note pad me likhna hy?......total kitniii files bnani hn kaisy mjhy kuch smjh nae a raha plzzz help.....

yes, you can paste it in Notepad and save like attachment

File name should be:

  • within Quotes ""
  • with extension .java

NOTE: this method is for NOTEPAD

Attachments:

RSS

Looking For Something? Search Below

Latest Activity

Ammara Sabir liked + !! Ήලᵯᵯℹ Ⲥⱨ !! +!!'s discussion !!!!JUMAAH MUBARIK ALL MUSLIMS!!!!
10 minutes ago
+ ❤ Spoken Girl updated their profile
11 minutes ago
Ammara Sabir commented on Ammara Sabir's video
25 minutes ago
Mani Siddiqui Ex posted a status
"“The greatest self is a peaceful smile, that always sees the world smiling back.”"
1 hour ago
+ !! Ήලᵯᵯℹ Ⲥⱨ !! +!! posted a status
"behtreen tjarba wo hy jis sy naseehat hasil ho"
1 hour ago
+ !! Ήලᵯᵯℹ Ⲥⱨ !! +!! posted a status
"badsurat chehra badsurat dimaagh sy bhtr hy"
1 hour ago
+ !! Ήලᵯᵯℹ Ⲥⱨ !! +!! posted a status
"jhoooth insaan aur imaan 2no ka dushman hy"
1 hour ago
+ !! Ήලᵯᵯℹ Ⲥⱨ !! +!! posted a status
"ALLAH KA KHOOF SB SY BARI DINAAI HY"
1 hour ago

© 2021   Created by + M.Tariq Malik.   Powered by

Promote Us  |  Report an Issue  |  Privacy Policy  |  Terms of Service