I'm confused the instructions say create a class called pizza with two fields PizzaType and Pieces. The Pizza constructor should call two data-entry methods GetType() and GetPieces() Is this the proper code for the constructor:
public pizza (string Types, int Pieces)

Recommended Answers

All 3 Replies

yes and no. that is a valid constructor but what I think your instructions want is

public pizza(){
getType();
getPieces();
}

private void GetType(){
//code to prompt user for type goes here
}


private void GetPieces(){
//code to prompt user for number of pieces
}

Hi,

I agree w/ previous post and want to say that instructions of your question are lame. I can't see a real world case where you call a user interactive method on a constructor.

Lore Soth

I'm a newbie at this programming stuff so there is alot of concepts I can't grasp right away. The instructions I supplied were a part of a project which included creating a exception class, creating a class with two methods that throw exceptions, and a class that establishes several objects and handles any throws. I going to assume that the book has me doing it this way for a reason. Perhaps because I didn't spell out the whole project, the instructions appear lame or it doesn't seem to apply to a real word case. You have to learn somehow. Thanks for the code sample that was supplied.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.