Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-18-2008, 12:54 PM
Member
 
Join Date: May 2008
Posts: 1
alcohole4life is on a distinguished road
Some input on a homework
Hi,guys I am a studying Computrer Science and Math in university, so I got a class this semester "Introduction to programming" in which we use Java. I have been doing below average having 65 points out of 100 on the first test and now I have to do three homeworks in the next three weeks and they will make up for 30% of the final grade. So here is my task for this week which is taken from a book of delitel "Java how to program 6th edition", so if anyone can give me any ideas where I can find solutions for it or sth. let me know.

1. Write the following classes following encapsulation and information hiding
conceptions:
-write class Point. its objects must have an array containing two integers, giving the cordinates of this point
-write three constructors for this class (for copying, main purpose and default), write set and get methods for the global variables and toString method
-write class Rectangle , which objects have an array with two Points and those 2 points give the up left corner and the down
-write three constructors for this class (for copying, main purpose and default), write set and get methods for the global variables and toString method(use the toString method from Point)
- write draw (Graphics g) method in class Rectangle that will let you draw the current "this object" by using the given as an argument object of class g
- write class Line , which objects have an array with two Points and they give the first and the last point of a line
- write three constructors for this class (for copying, main purpose and default), write set and get methods for the global variables and toString method(use the toString method from Point)
- write draw (Graphics g) method in class Line that will let you draw the current "this object" by using the given as an argument object of class g


2. Write enum Weekdays and its constants (NON,TUE, WED....) take 3 parameters the full name of the day, abbreviation of the full name and yhe positon of the day in the week. For example "Monday","Mon",1
Write a test class for this enum, which will randomly select a number from 1 to seven and it will output the following for this day:
a) The full names of the days of the week starting with the day which position was selected. For example with two we will have :Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday, Monday
b) the abbreviations of the days of the week in reverse order beginning with the picked number. For example for two we will have:
Tue , Mon , Sun , Sat , Fri , Thu , Wed

Ok. here is what I can do about it.
1.
- public class Point{private int[] cord= {1,2}
- public void setCord(int[] newCord)
{
if (NewGrade != null) {// set a copy of newGrade
Cord = new int[newCord.length][];

for (int i = 0; i < Cord.length; i++) {
Cord[i] = newCord[i];


}
} else {
Cord = new int[][]{{0}, {0}}; // by default

}}

public int getGrades(){
int[]temp = new int[Cord.length];

for (int j = 0; j < Cord[i].length; j++) {
temp[j] = Cord[i];
}
return temp;}
And gotta go now to eat but will write the rest of what I can do later today....
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 05-23-2008, 05:18 PM
Member
 
Join Date: May 2008
Posts: 2
radtad82 is on a distinguished road
int day = (int)(Math.random() * 7) + 1; //random# from 1 to 7
//go backwards
for (int i=day; i>=1; i--){
System.out.println(fullNameofDay(i));
}
for (int i=7; i>=day+1; i--){
System.out.println(fullNameofDay(i));
}
//go forwards
for (int i=day; i<=7; i++){
System.out.println(abbrDay(i));
}
for (int i=1; i<day; i++){
System.out.println(abbrDay(i));
}

Hopefully that should point you in the right direction
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Removal of Homework Requests CaptainMorgan Suggestions & Feedback 14 08-03-2008 10:21 PM
Tough Homework Questions, PLEASE HELP! passage New To Java 21 01-17-2008 12:04 AM
Help with my java servlet homework jellyfish888 Java Servlet 2 12-21-2007 06:41 PM
Homework PREREQUISITE Problem ChrisC New To Java 7 11-27-2007 06:36 AM
how to take input and verify input in Java programs bilal_ali_java Advanced Java 0 07-21-2007 09:46 AM


All times are GMT +3. The time now is 10:15 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org