ATILIM UNIVERSITY
DEPARTMENT OF COMPUTER ENGINEERING
COMPE 223 – OBJECT-ORIENTED PROGRAMMING
HOMEWORK I
Due Date: November 24, 2009, midnight.
Write a C++ program to simulate tomato crates (kasa) arriving to a depot (depo).
For this purpose, create class Crate with the following members:
• data members: city where it came from, arrival day (1≤arrival_day≤30), purchase price, status flag to describe the status of a crate (e.g. -1:not available, 1:available, and 0:sold).
Assumption: “arrival day” refers to day when tomatos are packaged to crate.
• Default constructor is used to initialize arrival day and purchase price to zero and also status to -1.
• Set member function is used to assign city, arrival day and purchase price from input parameters and then it updates the status by 1.
• Other member functions should be defined when required.
Create class Depot with:
• data members: A pointer to Crate objects with an array size 100. There are two static members that are publicly accessible. One of them is to hold total profit that can be calculated from
where sell price is 10 percent of purchase price. Other static data member is to represent total number of entry (entry≤100).
• Constructor dynamically creates an array of Crate objects (array size is assumed to be 100 so that there can be at most 100 sales per each month.
• arrival(entry) is a member function to set arrival day, price and city information for maximum number of entry (entry<=100) that represent the number of crates.
• sell() is member function
o to find the oldest crate arrived to the depot ;
o to sell it by setting its status to 0;
o to update the total profit for sales with a sell price (sell price is calculated as 10% purchase price for that crate)
• display() member function is used to display the total amount of sell profit for that month.
Program will display a menu to process arrivals/sales of crates as shown in the sample run.
Sample Run:
<1>: Arrival, <2>: Selling, <3>: Displaying, <4>: Quit
Enter your choice: 2
No crates to sell
<1>: Arrival, <2>: Selling, <3>: Displaying, <4>: Quit
Enter your choice: 1
Number of entry: 2
Enter arrival day: 10
purchase price: 100
city: Antalya
Enter arrival day: 15
purchase price: 200
city: Adana
<1>: Arrival, <2>: Selling, <3>: Displaying, <4>: Quit
Enter your choice: 2
Crate from Adana with arrival day 15 was sold with a price: 220
<1>: Arrival, <2>: Selling, <3>: Displaying, <4>: Quit
Enter your choice: 3
Total profit: 20
<1>: Arrival, <2>: Selling, <3>: Displaying, <4>: Quit
Enter your choice: 4
Bye
NOTE:
• You should mail your homework to Compe223@atilim.edu.tr address.
• Name your file as: name_surname_hw1.cpp. Do not use Turkish letters
• Write your name and homework number into subject of your email.
• The homework will be checked for cheating by a program.
• Late homework will be graded as: 100-10n*n where n is the number of late days.
hadi bakalım ugras dur :D
Gönderen kantinde kim var zaman: 14:17
Kaydol:
Kayıt Yorumları (Atom)
0 yorum:
Yorum Gönder