I'm new to java, im currently working on my first assignment.
And just so all of you are aware, i am doing distance education(which was a terrible idea) I have asked my professor through email for some direction or advice and she then told me that i should think about dropping out of the course. Which was no help at all.
Anywho,
The assignment i am required to complete is this:
"Design a card class that contains a character data field to hold a suit ('s' for spades, 'h' for hearts, 'd' for diamonds, and 'c' for clubs) and an integer data field for a value from 1 to 13. Include, get and set methods for each field."
The second part of the assignment asks this of me:
"Write an application that randomly selects two playing cards and prints their values. Simply assign a suit to each of the cards, but generate a random number for each card's value."
As i stated before, i'm simply looking for some direction.
I honestly have no idea where to start and im not getting any help or direction from my professor.
Any advice or help would be very appreciated.
Thank you very much.
Vanessa.
CARD JAVANew to java
Page 1 of 1
8 Replies - 2678 Views - Last Post: 22 December 2009 - 07:06 PM
Replies To: CARD JAVA
#2
Re: CARD JAVA
Posted 21 December 2009 - 09:05 PM
You might take a look into using the java.util.Random class for your random numbers:
http://java.sun.com/...til/Random.html
As for the rest of the assignment, it should be pretty self-explanatory. You might want to review your lessons on OOP.
If you need help with the code you've written for this assignment, feel free to post. Remember to include that code.
Sorry we can't be of more assistance, but it would be in violation of the rules.
http://java.sun.com/...til/Random.html
As for the rest of the assignment, it should be pretty self-explanatory. You might want to review your lessons on OOP.
If you need help with the code you've written for this assignment, feel free to post. Remember to include that code.
Sorry we can't be of more assistance, but it would be in violation of the rules.
#3
Re: CARD JAVA
Posted 21 December 2009 - 10:09 PM
vrichh, on 21 Dec, 2009 - 07:57 PM, said:
I'm new to java, im currently working on my first assignment.
And just so all of you are aware, i am doing distance education(which was a terrible idea) I have asked my professor through email for some direction or advice and she then told me that i should think about dropping out of the course. Which was no help at all.
Anywho,
The assignment i am required to complete is this:
"Design a card class that contains a character data field to hold a suit ('s' for spades, 'h' for hearts, 'd' for diamonds, and 'c' for clubs) and an integer data field for a value from 1 to 13. Include, get and set methods for each field."
The second part of the assignment asks this of me:
"Write an application that randomly selects two playing cards and prints their values. Simply assign a suit to each of the cards, but generate a random number for each card's value."
As i stated before, i'm simply looking for some direction.
I honestly have no idea where to start and im not getting any help or direction from my professor.
Any advice or help would be very appreciated.
Thank you very much.
Vanessa.
And just so all of you are aware, i am doing distance education(which was a terrible idea) I have asked my professor through email for some direction or advice and she then told me that i should think about dropping out of the course. Which was no help at all.
Anywho,
The assignment i am required to complete is this:
"Design a card class that contains a character data field to hold a suit ('s' for spades, 'h' for hearts, 'd' for diamonds, and 'c' for clubs) and an integer data field for a value from 1 to 13. Include, get and set methods for each field."
The second part of the assignment asks this of me:
"Write an application that randomly selects two playing cards and prints their values. Simply assign a suit to each of the cards, but generate a random number for each card's value."
As i stated before, i'm simply looking for some direction.
I honestly have no idea where to start and im not getting any help or direction from my professor.
Any advice or help would be very appreciated.
Thank you very much.
Vanessa.
Lol, I'm a java tutor and a professor that I work with assigns that project to her students every quarter. Whats your teachers name?
But this is what you would need to do,
You need to create a card class that holds a 2 private variables, one for suit and rank, whatever data type is up to you. What I always suggest to my tutees is to create a constructor that accepts 2 int parameters, first one is for suit and should only by 1-4 and the next one is rank which should be 1-13. Then the constructor takes care of those numbers and processes them into a suit and rank such as Ace of Spades. Or you can take care of determing the suit and make the constructor accept a char and an int
So basically, all you need to do is use that concept, create two cards, create a toString method so you can throw it in:
System.out.println(card1);
and so on
This post has been edited by HunterE30633: 21 December 2009 - 10:10 PM
#4
Re: CARD JAVA
Posted 22 December 2009 - 03:39 PM
HunterE30633, on 21 Dec, 2009 - 09:09 PM, said:
vrichh, on 21 Dec, 2009 - 07:57 PM, said:
I'm new to java, im currently working on my first assignment.
And just so all of you are aware, i am doing distance education(which was a terrible idea) I have asked my professor through email for some direction or advice and she then told me that i should think about dropping out of the course. Which was no help at all.
Anywho,
The assignment i am required to complete is this:
"Design a card class that contains a character data field to hold a suit ('s' for spades, 'h' for hearts, 'd' for diamonds, and 'c' for clubs) and an integer data field for a value from 1 to 13. Include, get and set methods for each field."
The second part of the assignment asks this of me:
"Write an application that randomly selects two playing cards and prints their values. Simply assign a suit to each of the cards, but generate a random number for each card's value."
As i stated before, i'm simply looking for some direction.
I honestly have no idea where to start and im not getting any help or direction from my professor.
Any advice or help would be very appreciated.
Thank you very much.
Vanessa.
And just so all of you are aware, i am doing distance education(which was a terrible idea) I have asked my professor through email for some direction or advice and she then told me that i should think about dropping out of the course. Which was no help at all.
Anywho,
The assignment i am required to complete is this:
"Design a card class that contains a character data field to hold a suit ('s' for spades, 'h' for hearts, 'd' for diamonds, and 'c' for clubs) and an integer data field for a value from 1 to 13. Include, get and set methods for each field."
The second part of the assignment asks this of me:
"Write an application that randomly selects two playing cards and prints their values. Simply assign a suit to each of the cards, but generate a random number for each card's value."
As i stated before, i'm simply looking for some direction.
I honestly have no idea where to start and im not getting any help or direction from my professor.
Any advice or help would be very appreciated.
Thank you very much.
Vanessa.
Lol, I'm a java tutor and a professor that I work with assigns that project to her students every quarter. Whats your teachers name?
But this is what you would need to do,
You need to create a card class that holds a 2 private variables, one for suit and rank, whatever data type is up to you. What I always suggest to my tutees is to create a constructor that accepts 2 int parameters, first one is for suit and should only by 1-4 and the next one is rank which should be 1-13. Then the constructor takes care of those numbers and processes them into a suit and rank such as Ace of Spades. Or you can take care of determing the suit and make the constructor accept a char and an int
So basically, all you need to do is use that concept, create two cards, create a toString method so you can throw it in:
System.out.println(card1);
and so on
My professor's name is Kerri Shields, out of Ontario Canada.
The question is from "Java Programming" by Joyce Farrell, fifth edition
I know i probably sound ridiculous for asking about such simple tasks, im just completely lost:)
Thank you all, any other info would be very generous.
#5
Re: CARD JAVA
Posted 22 December 2009 - 03:43 PM
vrichh, on 22 Dec, 2009 - 02:39 PM, said:
My professor's name is Kerri Shields, out of Ontario Canada.
The question is from "Java Programming" by Joyce Farrell, fifth edition
I know i probably sound ridiculous for asking about such simple tasks, im just completely lost:)
Thank you all, any other info would be very generous.
The question is from "Java Programming" by Joyce Farrell, fifth edition
I know i probably sound ridiculous for asking about such simple tasks, im just completely lost:)
Thank you all, any other info would be very generous.
You mean you haven't seen in class a bsic class with getter() and setter() ?
And we are in December, at the end of the trimester
#6
Re: CARD JAVA
Posted 22 December 2009 - 03:57 PM
pbl, on 22 Dec, 2009 - 02:43 PM, said:
vrichh, on 22 Dec, 2009 - 02:39 PM, said:
My professor's name is Kerri Shields, out of Ontario Canada.
The question is from "Java Programming" by Joyce Farrell, fifth edition
I know i probably sound ridiculous for asking about such simple tasks, im just completely lost:)
Thank you all, any other info would be very generous.
The question is from "Java Programming" by Joyce Farrell, fifth edition
I know i probably sound ridiculous for asking about such simple tasks, im just completely lost:)
Thank you all, any other info would be very generous.
You mean you haven't seen in class a bsic class with getter() and setter() ?
And we are in December, at the end of the trimester
No? i haven't
My course goes from december until the end of march.
#7
Re: CARD JAVA
Posted 22 December 2009 - 04:20 PM
Get and Set methods are simply ways of either retrieving or changing the values of private or protected Objects within a class.
For instance:
I would suggest looking up a tutorial on Java classes as a refresher.
For instance:
class A
{
private int x;
private int y;
//constructor, and all that good stuff
public int getX() //legal, since the class is able to access its own variables and manipulate them
{
return x;
}
public void setY(int a) //change the value of y
{
y = a;
}
}
//somewhere outside of the class
A obj = new A();
int a = obj.x; //illegal. x is private
int a = obj.getX(); //legal, the getX method is public
obj.y = 4; //illegal, y is private
obj.setY(4); //legal
I would suggest looking up a tutorial on Java classes as a refresher.
#8
Re: CARD JAVA
Posted 22 December 2009 - 06:51 PM
I DON'T EVEN KNOW WHERE TO START.
I have public class Card, and public static void main(String[] args) and THAT IS IT!
I need some serious help.
I have public class Card, and public static void main(String[] args) and THAT IS IT!
I need some serious help.
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote







|