-
August 7th, 2012, 07:58 AM
#1
help with choosing collection
Hey, I'm new to programmering so forgive me if my questions are not well formed.
I have been building on this rental program I found on the internet for some days. And my question is now I do I connect these classes in a good way?
For example if I have some textboxes on my windowsform and I wanted to created a new object with some movies details and I want to put in the ID name etc of the person barrowing it and storing it in some kind of collection. Any pointers?
Thank u
Code:
class Person
{
private int _id;
private string _name;
private string _adress;
private int _phonenr;
public string UserInfo { get { return _id + _name + _adress + _phonenr; } }
public Person(int id,string name, string adress, int phonenr)
{
this._name = name;
this._id = id;
this._adress = adress;
this._phonenr = phonenr;
}
}
public class Video
{
private static int _numb_of_films;
private int _year;
private string _director;
private string _title;
private bool _avalible = true;
public Video(string title, string director, int year)
{
Title = title;
this._director = director;
this._year = year;
_numb_of_films++;
}
public void SetVideo(string title, string director, int year)
{
this._title = title;
this._director = director;
this._year = year;
}
public bool IsAvailabe(bool avalible)
{
_avalible = avalible;
return this._avalible;
}
public bool Rented(bool rented)
{
_avalible = rented;
return this._avalible;
}
public string VideoInfo { get { return _year + " " + _title + " " + _director; } }
public static int NumOfFilms { get { return _numb_of_films; } }
}
-
August 7th, 2012, 09:28 AM
#2
Re: help with choosing collection
so are you saying you'd create a "rental", "borrow" or "checkout" object and have it hold a person and list of videos and the notes regarding that check out?
-
August 7th, 2012, 09:46 AM
#3
Re: help with choosing collection
Originally Posted by Magnus021
Hey, I'm new to programmering so forgive me if my questions are not well formed.
I have been building on this rental program I found on the internet for some days. And my question is now I do I connect these classes in a good way?
For example if I have some textboxes on my windowsform and I wanted to created a new object with some movies details and I want to put in the ID name etc of the person barrowing it and storing it in some kind of collection. Any pointers?
Thank u
Code:
class Person
{
private int _id;
private string _name;
private string _adress;
private int _phonenr;
public string UserInfo { get { return _id + _name + _adress + _phonenr; } }
public Person(int id,string name, string adress, int phonenr)
{
this._name = name;
this._id = id;
this._adress = adress;
this._phonenr = phonenr;
}
}
public class Video
{
private static int _numb_of_films;
private int _year;
private string _director;
private string _title;
private bool _avalible = true;
public Video(string title, string director, int year)
{
Title = title;
this._director = director;
this._year = year;
_numb_of_films++;
}
public void SetVideo(string title, string director, int year)
{
this._title = title;
this._director = director;
this._year = year;
}
public bool IsAvailabe(bool avalible)
{
_avalible = avalible;
return this._avalible;
}
public bool Rented(bool rented)
{
_avalible = rented;
return this._avalible;
}
public string VideoInfo { get { return _year + " " + _title + " " + _director; } }
public static int NumOfFilms { get { return _numb_of_films; } }
}
Are you talking about having a "rental" object that holds a person and a list of movies?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|