Design a class named pizza Data fields include a string field for toppings(such as pepperoni)and numeric field?
-
for diameter in inches (such as 12) and price (such as 13.99). Include methods to get and set values for each of these fields. Create the class diagram and write the pseudocode that defines the class.
-
Answer:
Here's Ruby code for the same: class Pizza attr_accessor :diameter, :price def initialize(d, p) @diameter = d.to_i @price = p.to_f end def display puts "Diameter: #{@diameter}, Price: #{@price} " end end puts "Enter diameter: " d = gets.chomp puts "Enter price: " p = gets.chomp p = Pizza.new(d, p) p.display
DMan at Yahoo! Answers Visit the source
Related Q & A:
- Is it correct to extend a bean class and write a class which holds logic to populate the bean we extend?Best solution by stackoverflow.com
- How to replace a string inside of a Word Document?Best solution by Stack Overflow
- Should I include a link to my online portfolio in my resume?Best solution by Quora
- What do I include in a resume when I've never had a job?Best solution by Yahoo! Answers
- What's the difference between a static data member and a regular data member?Best solution by eHow old
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.