944,193 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 447
  • Java RSS
Nov 7th, 2009
0

Help with Assignment

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Harris68 is offline Offline
6 posts
since Nov 2009
Nov 7th, 2009
0
Re: Help with Assignment
Anyhint for how to create the borrowvideo(Video v) methdoe
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Harris68 is offline Offline
6 posts
since Nov 2009
Nov 7th, 2009
0
Re: Help with Assignment
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.

Quote ...
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.

Java Syntax (Toggle Plain Text)
  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.
Featured Poster
Reputation Points: 2614
Solved Threads: 687
Posting Expert
VernonDozier is offline Offline
5,375 posts
since Jan 2008
Nov 8th, 2009
0

tnx

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.

Java Syntax (Toggle Plain Text)
  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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Harris68 is offline Offline
6 posts
since Nov 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: How to count the number of words
Next Thread in Java Forum Timeline: how to redirect speech received by Skype? //and Skype vs Fring





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC