the program will ask the personal information for each customer of a video club. It will save them at an array of 3 positions. Then we could do changes from a menu...
the code will take an automatic value each time we got a new client(object)
the number will count the number of the new clients
the program wll end when the user types the number 0 from the menu.
i have done something of that but i need your help with
the code
the number
and with the array
i don't know if the following are correct, please help...
using System;
class VideoClub
{
int code;
static int number;
string name;
int movies_bor;
public void SetName(string name)
{
this.name=name;
}
public string GetName()
{
return name;
}
public void SetMovBor(int movies_bor)
{
this.movies_bor = movies_bor;
}public double GetMoviesBor(){
return movies_bor;
}public void Borrow()
{
Console.WriteLine(" Name of client :{0} ", GetName());
Console.WriteLine(" number of Movies Borrowed : {0}", GetMovBor());
}
public void Return()
{
Console.WriteLine(" Name of client: {0}", GetName());
Console.WriteLine(" Number of movies want to return: {0}",GetMovBor());
}
}
public void Menu
{
int choice;
do{
Console.WriteLine("--Menu--");
Console.WriteLine("1. Borrow");
Console.WriteLine("2. Return");
Console.WriteLine("0. exit");
Console.WriteLine("Your choice is: ");
choice= (Int32.Parse(Console.ReadLine()));
Console.WriteLine(" the code of the client: ");
switch (choice)
{
case 1: Borrow(); break;
case 2: Return(); break;
case 0: break;
default: Console.WriteLine("wrong choice"); break;
}
}while(choice!=0);
}
}
}
}
class Program
{
static void Main()
{
VideoClub[] array= new VideoClub[3];
VideoClub client1= new VideoClub();
VideoClub client2= new VideoClub();
VideoClub client3= new VideoClub();
Console.WriteLine("first client");
Console.WriteLine("name: ");
client1.SetName(Console.ReadLine());
Console.WriteLine("number of movies has borrowed: ");
client1.SetMoviesB(Int32.Parse(Console.ReadLine()));
client1.Menu;
Console.WriteLine("second client");
Console.WriteLine("name: ");
client2.SetName(Console.ReadLine());
Console.WriteLine("number of movies has borrowed: ");
client2.SetMoviesB(Int32.Parse(Console.ReadLine()));
client2.Menu();
Console.WriteLine("third client");
Console.WriteLine("name: ");
client3.SetName(Console.ReadLine());
Console.WriteLine("number of movies has borrwed: ");
client3.SetMoviesB(Int32.Parse(Console.ReadLine()));
client3.Menu();
}
}
}
JuliaPosted May 8, 2011, 5:03 AM
VulpesPosted May 7, 2011, 2:16 PM
1. Create a Client class with name and movies borrowed fields plus a code field which is automatically allocated when the client joins the video club.
2. Create a VideoClub class which contains an array of 3 clients.
3. Populate the VideoClub with 3 new clients.
4. Ask the user to select a client by code and then choose whether to borrow additional or return existing videos or to quit altogether.
I've therefore tried to adjust your code to do all that below. Notice that the program is not 100% robust as some inputs could cause it to throw an exception: