Create several new objects within a for-loop in Java - java

I want to create several objects from a class in a for loop. but I don't know how to code it. What I have written creates a new object but it overwrites the previous object.
package assginment1_version4;
import java.util.*;
public class Client {
public static void main (String[] args) {
System.out.println ("this is a bill database");
System.out.println ("add a user?(Y/N)");
Scanner input = new Scanner(System.in);
String answer = input.nextLine ();
ArrayList ary = new ArrayList ();
for (int i=1 ; i < 100; i++) {
if (answer.equalsIgnoreCase("y")) {
Bill bill1 = new Bill();
System.out.println("user first name:");
bill1.setFname (input.nextLine());
System.out.println("user Last name:");
bill1.setLname (input.nextLine());
System.out.println ("add a user?(Y/N)");
answer = input.nextLine ();
} else if (answer.equalsIgnoreCase ("n")) {
if (Bill.getBillCounter () == 0) {
System.out.println ("the Database is empty");
break;
} else {
System.out.println ("Number of Users: "
+ Bill.getBillCounter ());
break;
}
} else {
while (!answer.equalsIgnoreCase ("n")
&& !answer.equalsIgnoreCase ("y")) {
System.out.println ("add a user?(Y/N)");
answer = input.nextLine ();
}
}
}
}
}
please help me to complete this code.

You're overriding them because you create a new Bill on each loop and never save them off anywhere. I believe you want to add them to your ArrayList:
First, you should add a type to your ArrayList:
ArrayList<Bill> ary = new ArrayList<Bill>();
Then, before you get the input from the user on whether or not to add a new Bill, you should add the current one to this list:
...
System.out.println("user Last name:");
bill1.setLname(input.nextLine());
ary.add(bill1);
...

You haven't used the ArrayList, you need to add the Bill's objects at the end of the for loop.
ary.add(bill1);
and add a type to your ArrayList
ArrayList<Bill> ary = new ArrayList<Bill>();

This is the Bill class.....
package assginment1_version2;
public class Bill {
/**
* Attributes of a bill
*/
private String firstName;
private String lastName;
private int paymentDeadline;
private int paymentCode;
private int billCode;
/**
* Attribute of Bill Class
*/
private static int BillCounter=0;
/**
* Methods of Bill class
* #return number of users
*/
/*public static int getBillCounter(){
return BillCounter;
}*/
/**
* Class Constructor
* #param Fname is the first name of user
* #param Lname is the last name of user
* #param Pdeadline is the deadline of paying the bill
* #param Pcode introduces the payment uniquely
* #param Bcode introduces the bill uniquely
*/
public Bill (){
BillCounter++;
}
/**
* FirstName methods
* method to set FirstName
* #param n is the input of setname method as a user name
*/
public void setFname (String n){
firstName=n;
}
// method to get FirstName
public String getFname (){
return firstName;
}
/**
* LastName methods
* method to set LastName
*/
public void setLname (String m){
lastName=m;
}
// method to get LastName
public String getLname(){
return lastName;
}
/**
* PaymentDeadline methods
* method to set PaymentDeadline
*/
public void setPaymentDeadline(int m){
paymentDeadline= m;
}
//method to get PaymentDeadline
public int getPaymentDeadline(){
return paymentDeadline;
}
/*
* PaymentCode methods
* Method to set PaymentCode
*/
public void setPaymentCode (int m){
paymentCode=m;
}
//method to get PaymentCode
public int getPaymentCode(){
return paymentCode;
}
/*
* Methods of BillCode
* method to set BillCode
*/
public void setBcode(int Bcode){
billCode=Bcode;
}
//method to get BillCode
public int getBcode(){
return billCode;
}
}

Related

Incompatible Types: Cannont be converted

So I've created a three classes; PetStore, Pet, and Bird. The PetStore class is the main class, pet extends PetStore and then Bird extends off of Pet
And now I've created a driver class with the following code.
public class Main{
public static void main(String[] args){
//create a pet objects
Bird macaw = new Bird("hyacinth macaw", 300.99, 48.0);
//create a pet store
PetStore happyPetsInc = new PetStore();
//add the pets to the pet store
happyPetsInc.addPet(macaw);
I'm trying to add the bird object to the arraylist in PetStore.
I'm getting the error: "incompatible types: Bird cannont be converted to java.lang.String"
someone flagged this and said to post the PetStore and Bird Class so here that is:
public class PetStore
{
//varibles
String pet;
//ArrayList
ArrayList<String> Pets = new ArrayList<String>();
//constructor
public PetStore(){
}
/**
* add the paramameter to the ArrayList
* #param pet
* #return void
*/
public void addPet(String pet){
Pets.add(pet);
}
/**
* removes the paramater to the ArrayList
* #param pet
* #return true(success) false(failure)
*/
public boolean sellPet(String pet){
this.pet = pet;
if (Pets.contains(pet)){
Pets.remove(pet);
return true;
}else{
return false;
}
}
/**
* counts the number of elements in the ArrayList
* #param none
* #return int, the number of the elements in Pets
*/
public int getInventoryCount(){
return Pets.size();
}
/**
* displays information about the pets in the ArrayList
* #param none
* #return void
*/
public String toString(){
for (int i = 0; i < Pets.size(); i++){
System.out.println("Pet #" + (i + 1));
String index = Pets.get(i);
return index.toString();
}
return "\n";
}
}
public class Bird extends Pet
{
//varibale
double wingspan;
//constuctor
public Bird(String species, double cost, double wingspan){
super(species, cost);
this.wingspan = wingspan;
}
/**
* Sets the wingspan of the bird
* #param wingspan
* #return none
*/
public void setWingspan(double wingspan){
this.wingspan = wingspan;
}
/**
* Gets the wingspan of the bird
* #param none
* #return double
*/
public double getWingspan(){
return this.wingspan;
}
/**
* Displays strings describing the bird
* #param none
* #return String
*/
public String toString(){
return "Species: " + species + "\nCost: $" + cost + "\nBird (Wingspan: " + wingspan + " inches)";
}
}
The idea of object oriented programming is, to have classes and instances of classes (objects) to represent real life objects. Hence, a PetStore is about pets, not strings. So do this:
In PetStore replace
ArrayList<String> Pets ...
addPet(String pet)...
sellPet(String pet)...
with
ArrayList<Pet> Pets
addPet(Pet pet)
sellPet(Pet pet)
Also, in PetStore.toString() replace
String index = Pets.get(i);
With
Pet index = Pets.get(i);
you should define a Pet class, then in PetStore change
String pet;
to
Pet pet;
and also
ArrayList<String> Pets = new ArrayList<String>();
to
ArrayList<Pet> Pets = new ArrayList<Pet>();

An ArrayList contains two elements, how to return only the String element?

I'm pretty new to Java but I feel like this is an easy task. This arraylist has two elements...names and scores. I want to write a method that prints a list of all the names in the list, not the scores. I know I've done this before I just can't remember how lol
import java.util.ArrayList;
/**
* Print test scrose and student names as well as he average for the class.
*/
public class TestScores {
private ArrayList<Classroom> scores;
public int studentScores;
/**
* Create a new ArrayList of scores and add some scores
*/
public TestScores() {
scores = new ArrayList<Classroom>();
}
/**
* Add a new student and a new score.
*/
public void add (String name, int score) {
scores.add(new Classroom(name, score));
if(score > 100){
System.out.println("The score cannot be more than 100");
}
}
/**
* Return all the student names.
*/
public void printAllNames() {//this is the method.
for (Classroom s : scores){
System.out.println(scores.get(name));
}
}
}
and the classroom class:
import java.util.ArrayList;
/**
* This class creates the names and scores of the students
*/
public class Classroom {
public int score;
public String name;
/**
* Constructor for the Class that adds a name and a score.
*/
public Classroom(String aName, int aScore) {
score = aScore;
name = aName;
}
/**
* Return the name of the students
*/
public String returnName() {
return name;
}
/**
* Return he scores
*/
public int returnScore() {
return score;
}
}
public void printAllNames() {//this is the method.
for (Classroom s : scores){
System.out.println(s.returnName());
}
}
You should be precice in your question, your list does not contain 2 elements - names and scores - but multiple Classroom objects which contain names and scores.
Alternative answer using Java 8 streams:
scores.stream().map(c -> c.returnName()).forEach(System.out::println);

Need help writing to a text file and storing information in array

I am having trouble writing the information typed in from the keyboard to a text file and storing it in an array.I get a null pointer exception within the text file when I try to print a new book object to that list. I have to open the text file, write to it, and add the new object to an array. I also am having formatting troubles with the menu, when you press "1" the menu asks you for the title and author simultaneously making it difficult to type an individual answer for each one. Here is my code:
Book Class: carries a toString method as well as information for certain variables
/**
* This class holds information regarding the title, author, and price variables
* #author
*
*/
public class Book {
String title;
String author;
double price;
public Book(String title, String author, int price) {
}
public String toString(){
return title + " by" + author + " ," + price;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
}
Book Input:
public class BookInput {
Scanner keyboard= new Scanner(System.in);
/**
* Reads the menu choice from the user
* #return
*/
public int readMenuChoice(){
int choice=keyboard.nextInt();
return choice;
}
/**
* Reads information for a new book object
* #return
*/
public Book readBook(){
System.out.print("Enter the book title: ");
String title=keyboard.nextLine();
System.out.print("Enter the author: ");
String author=keyboard.nextLine();
System.out.print("Enter the price: ");
int price=keyboard.nextInt();
Book b=new Book(title,author,price);
return b;
}
/**
* Reads the entire book list and returns the amount of objects in the array
* #param bookArray
* #param filename
* #return
*/
public int readBookList(Book[] bookArray, String filename){
Scanner inputStream=null;
int counter=0;
try
{
inputStream=new Scanner(new File(filename));
}
catch(FileNotFoundException e){
System.out.println("Error opening the file.");
System.exit(0);
}
for(int i=0; i<filename.length();i++){
bookArray[i]=readBook();
counter++;
}
return counter;
}
}
Book Output:
public class BookOutput {
PrintWriter outputStream=null;
/**
* Prints the menu for the user
*/
public void printMenu(){
System.out.println("1.Add a new book");
System.out.println("2.Display the book list");
System.out.println("3.Quit");
}
/**
* Prints the list of books that have been entered by the user
* #param bookArray
* #param size
*/
public void printBookList(Book[] bookArray, int size){
for(int i=0;i<size; i++){
System.out.println(bookArray[i].toString());
}
}
/**
* Opens the file to be written on
* #param filename
*/
public void openFileForAppend(String filename){
try
{
outputStream= new PrintWriter(filename);
}
catch(FileNotFoundException e){
System.out.println("Error opening the file.");
System.exit(0);
}
}
/**
* Writes information regarding a new book object to the file
* #param book
*/
public void writeBookToFile(Book book){
outputStream.println(book.toString());
}
/**
* closes the file
*/
public void closeFile(){
outputStream.close();
}
}
Main Driver:
public static void main(String[] args) {
BookInput i= new BookInput();
BookOutput o= new BookOutput();
Book [] bookArray = new Book[20];
String filename= "BookList.txt";
int size=i.readBookList(bookArray, filename);
o.openFileForAppend(filename);
o.printMenu();
int choice=i.readMenuChoice();
while(choice!=3){
switch(choice){
case 1:
Book book=i.readBook();
size++;
o.writeBookToFile(book);
break;
case 2:
o.printBookList(bookArray, size);
break;
default:
System.out.println("Invalid menu choice. Please try again");
break;
}
o.printMenu();
choice=i.readMenuChoice();
}
o.closeFile();
}
}
The constructor should assign the parameter values to the fields. To diaambiguate the field names, one can use this.
public Book(String title, String author, int price) {
this.title = title;
this.author = author;
this.price = price;
}
The parameter names are known only locally and do not get "wired" to the fields (as in some more rare programming languages).
Instead of using the keyboard, why not use a scanner? Just use an intermediate String object to save what the user has entered. This could help a little bit with the menu.
Also by using this, then you can just copy what the user entered into the book directly

java hirerequest() and processhirerequest() methods

Hi guys i have created two different classes which are a shopitem class and a shopuser class, I need to create two methods, hirerequest() and processhirerequest: below is my attempt at coding which has been unsucessful and will not compile:
/**
* Accessor method hireRequest
*
* #return shopuser and shopitem object's
*/
public String hireRequest()
{
return shop item object;
return shop user object;
}
/**
* Accessor method processHireRequest
*
* #return name
*/
public String processHireRequest()
{
return hireRequest;
}
is this above code correct and should it work??
any answers or help would be greatly appreciated.
code Shopitem:
public abstract class ShopItem
{
private ArrayList<Tool> toolsList;
Shop shop;
private int toolCount;
private String toolName;
private int power;
private int timesBorrowed;
private boolean rechargeable;
private int itemCode;
private int cost;
private double weight;
private boolean onLoan;
private static JFrame myFrame;
private String Tool;
private String ElectricTool;
private String HandTool;
private String Perishable;
private String Workwear;
private boolean ShopUserID;
public void ReadToolData (String data) throws FileNotFoundException,NoSuchElementException
{
// shows the directory of the text file
File file = new File("E:/LEWIS BC 2/java project/project 1 part 3/ElectricToolData.txt");
Scanner S = new Scanner (file);
// prints out the data
System.out.println();
// prints out the
System.out.println();
S.nextLine();
S.nextLine();
S.nextLine();
S.nextLine();
S.nextInt ();
}
/**
* Creates a collection of tools to be stored in a tool list
*/
public ShopItem(String toolName, int power,int timesborrowed,boolean rechargeable,int itemCode,int cost,double weight,int toolcount,boolean onLoan,boolean ShopUserID)
{
toolsList = new ArrayList<Tool>();
toolName = new String();
power = 0;
timesborrowed = 0;
rechargeable = true;
itemCode = 001;
cost = 100;
weight = 0.0;
toolCount = 0;
onLoan = true;
// ShopUserID = null;
}
/**
* Default Constructor for Testing
*/
public ShopItem()
{
// initialise instance variables
toolName = "Spanner";
itemCode = 001;
timesBorrowed = 0;
power = 0;
onLoan = true;
rechargeable = true;
itemCode = 001;
cost = 100;
weight = 0.0;
toolCount = 0;
}
/**
* Reads ElectronicToolData data from a text file
*
* #param <code>fileName</code> a <code>String</code>, the name of the
* text file in which the data is stored.
*
* #throws FileNotFoundException
*/
public void readData(String fileName) throws FileNotFoundException
{
//
// while (there are more lines in the data file )
// {
// lineOfText = next line from scanner
// if( line starts with // )
// { // ignore }
// else if( line is blank )
// { // ignore }
// else
// { code to deal with a line of ElectricTool data }
// }
myFrame = new JFrame("Testing FileDialog Box");
myFrame.setBounds(200, 200, 800, 500);
myFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
myFrame.setVisible(true);
{
FileDialog fileBox = new FileDialog(myFrame,
"Open", FileDialog.LOAD);
fileBox.setVisible(true);
}
{
File dataFile = new File(fileName);
Scanner scanner = new Scanner(dataFile);
while( scanner.hasNext() )
{
String info = scanner.nextLine();
System.out.println(info);
}
scanner.close();
}
}
/**
* Default Constructor for Testing
*/
public void extractTokens(Scanner scanner) throws IOException, FileNotFoundException
{
// extracts tokens from the scanner
File text = new File("E:/LEWIS BC 2/java project/project 1 part 3/items_all.txt");
String ToolName = scanner.next();
int itemCode = scanner.nextInt();
int cost = scanner.nextInt();
int weight = scanner.nextInt();
int timesBorrowed = scanner.nextInt();
boolean rechargeable = scanner.nextBoolean();
boolean onLoan = scanner.nextBoolean();
extractTokens(scanner);
// System.out.println(parts.get(1)); // "en"
}
/**
* Creates a tool collection and populates it using data from a text file
*/
public ShopItem(String fileName) throws FileNotFoundException
{
this();
ReadToolData(fileName);
}
/**
* Adds a tool to the collection
*
* #param <code>tool</code> an <code>Tool</code> object, the tool to be added
*/
public void storeTool(Tool tool)
{
toolsList.add(tool);
}
/**
* Shows a tool by printing it's details. This includes
* it's position in the collection.
*
* #param <code>listPosition</code> the position of the animal
*/
public void showTool(int listPosition)
{
Tool tool;
if( listPosition < toolsList.size() )
{
tool = toolsList.get(listPosition);
System.out.println("Position " + listPosition + ": " + tool);
}
}
/**
* Returns how many tools are stored in the collection
*
* #return the number of tools in the collection
*/
public int numberOfToolls()
{
return toolsList.size();
}
/**
* Displays all the tools in the collection
*
*/
public void showAllTools()
{
System.out.println("Shop");
System.out.println("===");
int listPosition = 0;
while( listPosition<toolsList.size() ) //for each loop
{
showTool(listPosition);
listPosition++;
}
System.out.println(listPosition + " tools shown" ); // display number of tools shown
}
public void printAllDetails()
{
// The name of the file to open.
String fileName = "ElectricToolDataNew.txt";
// This will reference one line at a time
String line = null;
try {
// FileReader reads text files in the default encoding.
FileReader fileReader =
new FileReader(fileName);
// Always wrap FileReader in BufferedReader.
BufferedReader bufferedReader =
new BufferedReader(fileReader);
while((line = bufferedReader.readLine()) != null) {
System.out.println(line);
}
// Always close files.
bufferedReader.close();
}
catch(FileNotFoundException ex) {
System.out.println(
"Unable to open file '" +
fileName + "'");
}
catch(IOException ex) {
System.out.println(
"Error reading file '"
+ fileName + "'");
// Or we could just do this:
// ex.printStackTrace();
}
}
}
code Shopuser
public abstract class ShopUser
{
private String name;
Shop shop;
private String shopUserID;
private String itemCode;
/**
* Constructor for objects of class ShopUser
*/
public ShopUser(String name, String shopUserID)
{
this.name = name;
this.shopUserID = shopUserID;
this.itemCode = itemCode;
}
// /**
// * Accessor method hireRequest
// *
// * #return shopuser and shopitem object's
// */
// public void hireRequest(String shopItem, String shopUser)
// {
// return shopItem;
// return shopUser;
// }
/**
* Accessor method getName
*
* #return name
*/
public String getName()
{
return name;
}
/**
* Accessor method getShopUserID
*
* #return shopUserID
*/
public String getShopUserID()
{
return shopUserID;
}
/**
* Method extractTokens that extracts tokens for a ShopUser object from a
* line of text that has been passed to the scanner
*
*/
public void extractTokens(Scanner scanner)
{
// data is name, shopUserID
name = scanner.next();
shopUserID = scanner.next();
}
/**
* Accessor method printDetails
*/
public void printDetails()
{
System.out.printf("%-15s %s %n", "name:", name);
System.out.printf("%-15s %s %n", "shop user ID:", shopUserID);
}
}
public String hireRequest() {
return shop item object;
return shop user object;
}
A method can only return ONE item.
Shop user object is never being called. You should have separate getters for shopUser and shopItem.

Subclasses and Superclasses

I'm trying to build a program that has certain requirements, the main being I have a class, and then make a subclass that adds a feature. I create the class DVD, and then I create the subclass.
I'm adding a method to add the year to the list, as well as a restocking fee which will be added to the final inventory value that prints. I built the subclass, created the overriding methods, but it is not being added to the output displayed. Not only that, but it is placing the input year in the wrong place. I am not getting any errors, it just acts like the subclass doesn't exist, even though my DVD class says that some of the methods are being overridden.
I'm thinking I must be missing something where I am supposed to call the new method, and maybe I read the resource wrong, but it sounded like I only needed to call the DVD class, and the methods I wanted overridden would be overridden automatically. I'd prefer to just add this information to the superclass, but it is a requirement for an assignment.
So I'm wondering how do I actually go about calling these override methods when I need them to add these new features? I keep seeing resources telling me how to create them, but not actually implement them.
From my main method, I call the dvd class and then print it. however, it only prints what's in the original dvd class, except for the odd addition of adding the year to where the product ID should be.
public class DVD {
String name;
int id;
int items;
double cost;
//default constructor
public DVD() {
name = "";
id = 0;
items = 0;
cost = 0.0;
}//end default constructor
//constructor to initialize object
public DVD(String dvdName, int itemNum, int quantity, double price) {
name = dvdName;
id = itemNum;
items = quantity;
cost = price;
}//end constructor
//method to calculate value
public double getInventoryValue() {
return items * cost;
}
//method to set name
public void setdvdName(String dvdName){
this.name = dvdName;
}
//method to get name
public String getName(){
return name;
}
//method to set id
public void setitemNum( int itemNum){
this.id = itemNum;
}
//method to get id
public int getId(){
return id;
}
//method to set items
public void setquantity(int quantity){
this.items = quantity;
}
//method to get items
public int getItems(){
return items;
}
//method to set cost
public void setprice( double price){
this.cost = price;
}
//method to get cost
public double getCost(){
return cost;
}
/**
*
* #return
*/
public String toString() {
return "DVD Name: " + getName() +
"ID: " + getId() +
"Items: " + getItems() +
"Cost: " + getCost() +
"Total Value: " +getInventoryValue();
}
}
-
public class ExtendedDVD extends DVD{
double restockFee;
int year;
public ExtendedDVD(){
year = 0;
}
public ExtendedDVD(int year) {
this.year = year;
}
public void setRestockFee(){
this.restockFee = 0.05;
}
public double getRestockFee(){
return restockFee;
}
public void setYear(){
this.year = 0;
}
public int getYear(){
return year;
}
#Override
public double getInventoryValue(){
double value1 = super.getInventoryValue();
double value = restockFee * value1;
double totalInventoryValue = value + super.getInventoryValue();
return totalInventoryValue;
}
#Override
public String toString(){
return super.toString() + "Year" + getYear();
}
}
}
public class Inventory {
DVD[] inventory = new DVD[5];
int current = 0;
private int len;
public Inventory(int len){
inventory = new DVD[len];
}
public double calculateTotalInventory() {
double totalValue = 0;
for ( int j = 0; j < inventory.length; j++ )
totalValue += inventory[j].getInventoryValue();
return totalValue;
}
/**
*
* #param dvd
* #throws Exception
*/
public void addDVD(DVD dvd) throws Exception {
if (current < inventory.length) {
inventory[current++]=dvd;
}else {
Exception myException = new Exception();
throw myException;
}
}
void sort() {
for (DVD inventory1 : inventory) {
len = current;
}
for (int i=0; i<len;i++) {
for(int j=i;j<len;j++) {
if (inventory[i].getName().compareTo(inventory[j].getName())>0) {
DVD temp = inventory[j];
inventory[j] = inventory[i];
inventory[i] = temp;
}
}
}
}
public int getNumberOfItems() {
return current;
}
public void printInventory() {
System.out.println("Current Inventory:");
for(int i=0;i<current;i++) {
System.out.println(inventory[i]);
}
System.out.println("The total value of the inventory is:"+calculateTotalInventory());
}
}
-
public class inventoryprogram1 {
/**
* #param args the command line arguments
*/
public static void main(String[] args){
boolean finish = false;
String dvdName;
int itemNum;
int quantity;
double price;
int year = 0;
Inventory inventory = new Inventory(5);
while (!finish) {
Scanner input = new Scanner(System.in); // Initialize the scanner
System.out.print("Please enter name of DVD: ");
dvdName = input.nextLine();
if (dvdName.equals("stop")) {
System.out.println("Exiting Program");
break;
} else {
System.out.print("Please enter Product Number: ");
itemNum = input.nextInt();
System.out.print("Please enter units: ");
quantity = input.nextInt();
System.out.print("Please enter price of DVD: ");
price = input.nextDouble();
System.out.print("Please enter production year: ");
itemNum = input.nextInt();
DVD dvd= new DVD(dvdName,itemNum,quantity,price);
try {
inventory.addDVD(dvd);
}catch( Exception e) {
System.out.println("Inventory is full.");
break;
}
System.out.println("DVD: " + dvd);
}//end else
}
inventory.sort();
inventory.printInventory();
}
}
if you want to use the new methods that you wrote in ExtendedDVD you need to instantiate that class you are still calling the original dvd class so you will still get those methods.
for example
DVD dvd = new DVD(dvdName, itemNum, quantity, price);
and
DVD Dvd = new ExtendedDVD(dvdName, itemNum, quantity, price);
are two different things
also if you look in your main method you are assigning itemNum twice that is why it is showing you the year
In the main method you just instantiate a DVD object, not an ExtendedDVD object.
replace
DVD dvd= new DVD(dvdName,itemNum,quantity,price);
by something like
DVD dvd= new ExtendedDVD(year);
And obviously, you may want another constructor in ExtendedDVD

Categories

Resources