0% found this document useful (0 votes)
36 views

Assignment 1 Programming II Fall 2024

Assignment_1_Programming_II_Fall_2024

Uploaded by

Sami Saad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views

Assignment 1 Programming II Fall 2024

Assignment_1_Programming_II_Fall_2024

Uploaded by

Sami Saad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

.

‫ﻻ ﺑﺪ ﻋﻠﻰ اﻟﻄﺎﻟﺐ أن ﯾﻘﻮم ﺑﮭﺬا اﻟﻮاﺟﺐ ﺑﻨﻔﺴﮫ ﻟﯿﺤﺴﻦ ﻣﮭﺎراﺗﮫ ﻓﻲ اﻟﺒﺮﻣﺠﺔ‬

Omar Al-Mukhtar University


Department of Computer Science
CSCI133 – Programming II
Fall 2024
Assignment 1

Type: Individual student

Due Date: By 11:59PM Sunday, October 27, 2024

Evaluation: Worth of 3 marks (see marks distribution at the end of handout)

None accepted! Simply, do not submit your work late!!


Late Submission:
!!‫ﺳﯿﺤﺼﻞ اﻟﻄﺎﻟﺐ ﻋﻠﻰ ﺻﻔﺮ إذا ﺗﺄﺧﺮ ﻋﻦ ﻣﻮﻋﺪ اﻟﺘﻘﺪﯾﻢ‬

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.

General Guidelines When Writing Programs:


- Include the following comments at the top of your source code for each file.

/****************************************************
* 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.

Assignment 1 for CSCI133 – Programming II/Fall 2024 ‫ رﺑﯿﻊ ﻣﻔﺘﺎح اﻟﻌﻠﻮاﻧﻲ‬.‫د‬ 1


.‫ﻻ ﺑﺪ ﻋﻠﻰ اﻟﻄﺎﻟﺐ أن ﯾﻘﻮم ﺑﮭﺬا اﻟﻮاﺟﺐ ﺑﻨﻔﺴﮫ ﻟﯿﺤﺴﻦ ﻣﮭﺎراﺗﮫ ﻓﻲ اﻟﺒﺮﻣﺠﺔ‬

Part 1: Defining a Pizza Class:


Create a class named Pizza that stores information about a single pizza. It should contain the
following:

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.

Pizza cost is determined by:


- Small: $10 + $2 per topping
- Medium: $12 + $2.25 per topping
- Large: $14 + $2.50 per topping.

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.

Part 2: Write a test code to:

1. Create 3 different pizzas: First one with the default constructor, and for the 2nd and third
one prompt the user.

2. Output the descriptions of the 3 pizzas.

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.

Assignment 1 for CSCI133 – Programming II/Fall 2024 ‫ رﺑﯿﻊ ﻣﻔﺘﺎح اﻟﻌﻠﻮاﻧﻲ‬.‫د‬ 2


.‫ﻻ ﺑﺪ ﻋﻠﻰ اﻟﻄﺎﻟﺐ أن ﯾﻘﻮم ﺑﮭﺬا اﻟﻮاﺟﺐ ﺑﻨﻔﺴﮫ ﻟﯿﺤﺴﻦ ﻣﮭﺎراﺗﮫ ﻓﻲ اﻟﺒﺮﻣﺠﺔ‬

Note: Assume the user enters valid input.

Here is a sample output screen:


Text in gray are user input

************************************************
** Welcome to Jamal Khaled's Pizza Shop **
************************************************

Please place order for 1st pizza:


Size: small, medium or large? small
Indicate the number of each of the following topping:
Cheese : 1
Pepperoni : 2
Mushroom : 3

Please place order for 2nd pizza:


Size: small, medium or large? large
Indicate the number of each of the following topping:
Cheese : 3
Pepperoni : 2
Mushroom : 1

Here are the three pizzas:


A pizza with 0 cheese topping(s), 0 pepperoni topping(s) and 0 mushroom topping(s) cost $0.0
A SMALL pizza with 1 cheese topping(s), 2 pepperoni topping(s) and 3 mushroom topping(s) cost $22.0
A LARGE pizza with 3 cheese topping(s), 2 pepperoni topping(s) and 1 mushroom topping(s) cost $29.0

Results of comparisons:
None of the pizzas are the same

Results of comparisons after changing one of the pizzas . . .


First and second pizza are the same.
A SMALL pizza with 1 cheese topping(s), 2 pepperoni topping(s) and 3 mushroom topping(s) cost $22.0
Pizza 3:
A LARGE pizza with 3 cheese topping(s), 2 pepperoni topping(s) and 1 mushroom topping(s) cost $29.0

Enjoy the pizzas . . .

Assignment 1 for CSCI133 – Programming II/Fall 2024 ‫ رﺑﯿﻊ ﻣﻔﺘﺎح اﻟﻌﻠﻮاﻧﻲ‬.‫د‬ 3


.‫ﻻ ﺑﺪ ﻋﻠﻰ اﻟﻄﺎﻟﺐ أن ﯾﻘﻮم ﺑﮭﺬا اﻟﻮاﺟﺐ ﺑﻨﻔﺴﮫ ﻟﯿﺤﺴﻦ ﻣﮭﺎراﺗﮫ ﻓﻲ اﻟﺒﺮﻣﺠﺔ‬

Guideline for Submitting Assignment 1:

- Create a Java file for each part.


- Zip the source code (the .java files only please) of this assignment.
- Naming convention for zip file: Create one zip file, containing the source files for your
assignment using the following naming convention:
- The zip file should be called A#_studentID, where # is the number of the
assignment and studentID is your student ID number.
- For example, for the first assignment, student 9929939 would submit a zip file
named A1_9929939.zip
- Submit your zip file at: the course Google Classroom.
- Please visit this webpage to learn more about how to submit an assignment to
Google Classroom:
https://support.google.com/edu/classroom/answer/6020285?hl=en&co=GENIE.Pl
atform%3DDesktop
- Assignments not submitted to the correct location will not be graded.

Evaluation Criteria for Assignment 1 (9/3 points):

Source Code Point(s)


Part I (Class Pizza) 5 pts
- Default & copy constructors 1 pt
- Accessor/mutator methods 1 pt
- equals and toString methods 3 pt
Part II (Driver class) 4 pts
- main method & user prompting 1 pt
- comparing objects 1 pt
- General quality and correctness of code & functionality 2 pts
Total = 9/3

Assignment 1 for CSCI133 – Programming II/Fall 2024 ‫ رﺑﯿﻊ ﻣﻔﺘﺎح اﻟﻌﻠﻮاﻧﻲ‬.‫د‬ 4

You might also like