-
December 4th, 2010, 09:02 PM
#1
New to programming, need help with assignment
any help is appreciated!
This is for an assignment, its quite basic stuff as were new to it and i went through the practice stuff in the book and fount it easy enough so i thought id get this but im stuck whenn it comes to this work, Grr!
ok so the questions are;
"2.1 Add an Order class to your project to store the following information about an Order: the Order's reference number, the customer's name , a description and total cost. In addition, the class also stores the order's call-in time and the delivered time (all of type Time).
2.2 Write a constructor which sets the order reference number, customer name, description, total cost and call-in time from suitable formal parameters. Call-in time should be represented by two formal parameters of type int which are passed as actual parameters to a Time constructor. The delivered time should initially be set to null."
Im having problems with making this "Order" class, i get confused where the two classes mix :/
this is some of the time class;
public class Time
{
//fields
private int hour;
private int minute;
//constructor
public Time ()
{
hour = 0;
minute = 0;
}
//method
private void setHour(int newHour)
{
if ((newHour >= 0) & (newHour < 24)) {
hour = newHour;
}
else{
hour=0;
}
//##more methods down here##
}
and well heres what ivei done in the "Order" class which im supposed to be doing now
public class Order
{
// 2.1 - fields
private int orderNumber;
private String customerName;
private String description;
private int totalCost;
private Time callInTime;
private Time deliveredTime;
//2.2 - constructor
public Order (int newOrderNumber, String newCustomerName, String newDescription, int newTotalCost )
{
orderNumber = newOrderNumber;
customerName = newCustomerName;
description = newDescription;
totalCost = newTotalCost;
callInTime = ;
deliveredTime = ;
}
-----------
so i basically have no idea where to start or what to do, ive played about with a few ideas buy none worked. Ever since i started i just looked at similar stuff and taught myself from that but i cant find anything like this that so im looking for help with this part and i so i can look over whatever you guys have done and teach myself when it comes up later (very similar question a few after this which im hoping to be able to do without asking for help
thanks for any help
-
December 6th, 2010, 05:37 AM
#2
Re: New to programming, need help with assignment
Your Time class handles time as two int values so you need a constructor to allow you pass in two int values to set the time.
Your Order constructor also requires two int values to represent the call-in time.
The homework states to set the deliveredTime to null so I'm not sure why you haven't been able to do this part.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|