Assignment 1 Programming II Fall 2024
Assignment 1 Programming II Fall 2024
The purpose of this assignment is to help students learn and practice some
of the main topics covered in the first part of this course, including classes,
Purpose:
loops, getters, setters. It also focuses on problem analysis, design
solutions, writing, testing source code, and communication skills.
/****************************************************
* Assignment (include number) - (question number/part number)
* Written by: (include your name and student ID)
* For CSCI13 - Programming II - Fall 2024
*****************************************************/
- In a comment, give a general explanation of what your program does. As the programming
questions get more complex, the explanations will get lengthier.
- Include comments in your program describing the main steps in your program.
- Display a welcome message which includes your name.
- Display clear prompts for users when you are expecting the user to enter data from the
keyboard.
- All output should be displayed with clear messages and in an easy-to-read format.
- End your program with a closing message so that the user knows that the program has
terminated.
1. Private instance variables to store the size of the pizza (Small, Medium or Large), the number
of cheese toppings, the number of pepperoni toppings, and the number of mushroom toppings.
2. Constructors:
- One that takes four arguments and sets all of the corresponding instance variables.
- A default constructor, that takes no arguments and initializes all instance variables to the
‘zero’ of their type.
3. Methods to get (accessor) and set (mutator) each instance variable individually.
4. A public method called calcCost() that returns a double that is the cost of the pizza.
For example, a large pizza with 1 cheese, 2 pepperoni and 1 mushroom toppings should cost $24
(14 + 4 x $2.50) while a small pizza with the same toppings will cost $18 (10 + 4 x $2).
5. A toString() method which takes no arguments and returns a string the pizza size, quantity of
each topping, and the pizza cost as calculated by .
6. An equals() method which is redefined to test for the equality of the content of 2 objects of
type Pizza.
1. Create 3 different pizzas: First one with the default constructor, and for the 2nd and third
one prompt the user.
3. Compare the 3 pizzas and display a message saying whether they are identical in content or
not. Make sure you code test for the following scenarios when comparing the pizzas: that all
three are the same, only 2 are the same, or none are the same.
4. Change the first pizza’s content to be the same as one of the other ones.
5. Compare the 3 pizzas again and display a message saying whether they are identical in
content or not as well as their contents.
************************************************
** Welcome to Jamal Khaled's Pizza Shop **
************************************************
Results of comparisons:
None of the pizzas are the same