Help with Assignment

Reply

Join Date: Nov 2009
Posts: 6
Reputation: Harris68 is an unknown quantity at this point 
Solved Threads: 0
Harris68 Harris68 is offline Offline
Newbie Poster

Help with Assignment

 
0
  #1
15 Days Ago
Hi,

I ap posting my Assignment subject here, and hope to get some helps with each Classes, I am not asking that you do all my home works but to give me hints as I want to learn something and as I am new to Java I am block some times.

this is the Subject
****************************************************
The program allows customers to list the videos available and to borrow them (ignore returning videos). It
records whether a video is on the shelf or on loan, and if it is on loan, the date it is due to be returned.
Customers can borrow up to two videos for 3 days. Build the program according to the following recipe:
1. There should be classes describing customers and videos and also a class called VideoStore that
contains ArrayLists of customers and videos. There should also be a small public class VideoTest
that contains the main() method.

2. The Video class has instance fields for the video title, whether it is on loan and the date it is due to be
returned. There are get and set methods for some of these fields and a toString() method.

3. The Customer class has instance fields for the customer name and for the number of videos he is
borrowing. A method borrowvideo(Video v) checks that the video is available and that the
customer is not borrowing more than 2 videos, it then sets the duedate and onloan fields in the Video
class. The due date is printed on screen. There is a get method for the customer name.

4. The constructor for the VideoStore class initialises a small number (less than 10) of Customer and
Video objects and stores them in two separate ArrayLists that are the instance fields for the class. It
provides a method (listallvideos()) for listing all the videos in the store and a method called
borrow(String,String) described below.

5. The main method in VideoTest creates a VideoStore, then enters a loop that implements a menu:
"Menu: L-List, B-Borrow, Q-Quit". A Scanner picks up the letter entered and causes the desired
response. List, lists the titles of all the videos along with whether they are on the shelf or the due date
if they are on loan. Quit, drops out of the loop and exits the application. Borrow, asks first the
Customer's name, and then the title of the video he wishes to borrow and picks up responses with a
Scanner. These are then passed to the VideoStore borrow method as borrow(name,title).

6. The VideoStore borrow method checks that the name and title match entries in the VideoStore arrays,
and identifies the Customer and Video objects they correspond to. The Customer
borrowvideo(Video v) method can then be called.

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

this is my VideoTest Class
*****************************************************

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package assignement;
import java.util.*;
/**
*
* @author Harris
*/
public class VideotTest {

public static void main(String[] args)
{
VideoStore vs = new VideoStore();

Scanner sc = new Scanner(System.in);
String menuResponse;
do
{

System.out.println("Menu: L-list, B-borrow, Q-quit");
menuResponse = sc.nextLine();

if(menuResponse.equals("L"))
vs.listallvideos();
else if (menuResponse.equals("B"))
{
System.out.println("What is your name?");
String nameResponse = sc.nextLine();

System.out.println("What is the title of the video you want to borrow?");
String videoResponse = sc.nextLine();
// vs.borrow(nameResponse,videoResponse);
}
} while(!menuResponse.equalsIgnoreCase("Q"));
}
}

*****************************************************
this is my VideoStore Class
*****************************************************
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package assignement;
import java.util.*;
/**
*
* @author Harris
*/
public class VideoStore {

private String VideoName;
private String CustomersName;
private ArrayList<String> Videos = new ArrayList<String>();
private ArrayList<String> CustomersListe = new ArrayList<String>();


public VideoStore(){
VideoName = null;
CustomersName = null;


}


public VideoStore(String VidName, String CustName){

VideoName = VidName;
CustName = CustomersName;


Videos.add("Brave Heart");
Videos.add("Troy");
Videos.add("Shakspear In Love");
Videos.add("Green Mile");
Videos.add("Ice Age");

CustomersListe.add("Harris");
CustomersListe.add("John");
CustomersListe.add("Ricky");
CustomersListe.add("Mike");
CustomersListe.add("Robin");
}

public String getVideoName(){
return VideoName;
}
public String getCustomersName(){
return CustomersName;
}



public void listallvideos(){

for (int i = 0; i < Videos.size(); i++)
System.out.println(Videos.get(i));
}

}

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

the problem which I get is when I run VideoTest which is my main class by chosing L it dosnt not list my Videos list which is an Array list it goes back to the menu.
Anyone Can Help?

Thanks
Reply With Quote Quick reply to this message  
Join Date: Nov 2009
Posts: 6
Reputation: Harris68 is an unknown quantity at this point 
Solved Threads: 0
Harris68 Harris68 is offline Offline
Newbie Poster
 
0
  #2
15 Days Ago
Anyhint for how to create the borrowvideo(Video v) methdoe
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 3,810
Reputation: VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute 
Solved Threads: 501
Featured Poster
VernonDozier VernonDozier is offline Offline
Senior Poster
 
0
  #3
15 Days Ago
Code tags and formatting please. The code is unreadable now as it is.


[code=JAVA]
// code here
[/code]



Before you can work on the borrowing function, you need to set up your ArrayLists correctly.

There should be classes describing customers and videos and also a class called VideoStore that
contains ArrayLists of customers and videos.
I read that as saying that you need an ArrayList of type Customer and an ArrayList of type Video. Right now you have them as Strings.

  1. private ArrayList<String> Videos = new ArrayList<String>();
  2. private ArrayList<String> CustomersListe = new ArrayList<String>();

You definitely need a Customer and Video class, as stated in points 2 and 3 in the assignment. You don't have them yet. You need them before you set up your ArrayLists.

That's my interpretation of the assignment.
Reply With Quote Quick reply to this message  
Join Date: Nov 2009
Posts: 6
Reputation: Harris68 is an unknown quantity at this point 
Solved Threads: 0
Harris68 Harris68 is offline Offline
Newbie Poster

tnx

 
0
  #4
15 Days Ago
Originally Posted by VernonDozier View Post
Code tags and formatting please. The code is unreadable now as it is.


[code=JAVA]
// code here
[/code]



Before you can work on the borrowing function, you need to set up your ArrayLists correctly.




I read that as saying that you need an ArrayList of type Customer and an ArrayList of type Video. Right now you have them as Strings.

  1. private ArrayList<String> Videos = new ArrayList<String>();
  2. private ArrayList<String> CustomersListe = new ArrayList<String>();

You definitely need a Customer and Video class, as stated in points 2 and 3 in the assignment. You don't have them yet. You need them before you set up your ArrayLists.

That's my interpretation of the assignment.

hi there thanks for the replay,

I did change the ArrayLists and its workin gnow I already created the other two classes, Customers and Videos, any idea how to to do that borrowvideo and borrow methot?

thanks
Reply With Quote Quick reply to this message  
Reply

Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC