Need help getting started with program .....

C

coolcsgeek

i took a c++ intro cs course a few years back and recently decided to
major in cs after much switching back and forth between majors. it
seems my school has replaced most of it's intro level cs courses to
java making c++ obsolete! whether this is a good idea or not that is a
discussion for another day. anyway learning a new language is never
easy and the professor has assigned the following problem to us and i
am completely lost! if anyone can push me in the right direction in
writing this program i'd highly appreciate it.

--
Design and implement the class Day that implements the day of the week
in a program. The class Day should store the day, such as Sun for
Sunday. The program should be able to perform the following operations
on an object of the type Day:

a) Set the day
b) Print the day
c) Return the day
d) Return the next day
e) Return the previous day
f) Calculate and return a day by adding # of days to current day.
(ie. if current day is Monday and we add 3 days then new day
is Thursday)
g) Add the appropiate constructors // default & set constructors
h) Write the definitins of the methods to implement the
operations for the class Day as defined in a - g
i) Write a program to test various operations on the class Day


/* here is what i've done so far .. not much but you got to start
somewhere correct me if i'm wrong */

class week {
string [] days = {"mon","tue","wed","thu","fri","sat","sun"};
// set the days
int i = 0;
for (i < 8; i++ ) {
System.out.print(days); // print days using index?
}

public class returnDays {
return days[];
}

/* that's as far as i've gotten so far.. any help would be
highly appreciated can someone explain to me what exactly
the constructors job is? also how to properly use an
index because i know i screwed that up.. */
 
R

Ryan Stewart

coolcsgeek said:
i took a c++ intro cs course a few years back and recently decided to
major in cs after much switching back and forth between majors. it
seems my school has replaced most of it's intro level cs courses to
java making c++ obsolete! whether this is a good idea or not that is a
discussion for another day. anyway learning a new language is never
easy and the professor has assigned the following problem to us and i
am completely lost! if anyone can push me in the right direction in
writing this program i'd highly appreciate it.

--
Design and implement the class Day that implements the day of the week
in a program. The class Day should store the day, such as Sun for
Sunday. The program should be able to perform the following operations
on an object of the type Day:

a) Set the day
b) Print the day
c) Return the day
d) Return the next day
e) Return the previous day
f) Calculate and return a day by adding # of days to current day.
(ie. if current day is Monday and we add 3 days then new day
is Thursday)
g) Add the appropiate constructors // default & set constructors
h) Write the definitins of the methods to implement the
operations for the class Day as defined in a - g
i) Write a program to test various operations on the class Day


/* here is what i've done so far .. not much but you got to start
somewhere correct me if i'm wrong */

class week {
string [] days = {"mon","tue","wed","thu","fri","sat","sun"};
// set the days
int i = 0;
for (i < 8; i++ ) {
System.out.print(days); // print days using index?
}

public class returnDays {
return days[];
}

/* that's as far as i've gotten so far.. any help would be
highly appreciated can someone explain to me what exactly
the constructors job is? also how to properly use an
index because i know i screwed that up.. */

Actually your indexed array access is syntactically correct. But you can't put
code directly in a class. You have to write methods. Your returnDays class
especially should be a method. Further, your assignment was to write a Day
class. You don't even have the word "Day" in your code. Start by reading some of
your textbook. Otherwise you can start here:
http://java.sun.com/docs/books/tutorial/

Finally, in the future do not crosspost among the comp.lang.java.* groups, and
do not post at all to comp.lang.java. That group is deprecated. Your posts would
be better received in comp.lang.java.help, which is a group for beginners.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top