| | |
Help with Assignment
![]() |
•
•
Join Date: Nov 2009
Posts: 6
Reputation:
Solved Threads: 0
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
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
•
•
Join Date: Jan 2008
Posts: 3,810
Reputation:
Solved Threads: 501
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.
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.
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.
[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.
Java Syntax (Toggle Plain Text)
private ArrayList<String> Videos = new ArrayList<String>(); 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.
•
•
Join Date: Nov 2009
Posts: 6
Reputation:
Solved Threads: 0
•
•
•
•
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)
private ArrayList<String> Videos = new ArrayList<String>(); 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
![]() |
Similar Threads
- help me in my assignment... (C++)
- Help needed with VB Assignment (Visual Basic 4 / 5 / 6)
- Many Errors while doing this assignment (C)
- I need help on my 'address book' assignment! (C++)
Other Threads in the Java Forum
- Previous Thread: How to count the number of words
- Next Thread: how to redirect speech received by Skype? //and Skype vs Fring
| Thread Tools | Search this Thread |
account android api applet application array arrays automation bidirectional binary birt bluetooth class classes client code columns component constructor database designadrawingapplicationusingjavajslider draw eclipse error errors exception expand fractal game givemetehcodez graphics gui guidancer homework html ide image inetaddress inheritance integer intellij j2me java javamicroeditionuseofmotionsensor javaprojects jlabel jme jni jpanel jtextfield jtree julia linux list loop map method methods midlethttpconnection mobile mobiledevelopmentcreatejar monitoring myaggfun netbeans newbie nullpointerexception open-source oracle plazmic print problem program project property recursion ria scanner search server set sharepoint smart sms smsspam sort sourcelabs splash sql sqlite static string subclass support swing testautomation threads tree unlimited webservices windows






