Julia

Julia

  • NA
  • 8
  • 3.3k

help with a problem - array

May 7 2011 7:27 AM
hello, i don't know if here is the right place to write... if it isn't move my post...

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();

}

}
}



Answers (2)