TheLstSpartan
05-26-2008, 03:41 AM
Ive accidently posted this in JavaScript section :rolleyes:
But anyway,
I am taking Java in high school as my graduation requirement. And as our final project we are to make Deal or no Deal game on JCreator.
Now the most recent topic we covered was ArrayLists, we also covered topics like for/while loops, Exceptions and etc...
i have so far been able to print the money values and cases. So yea i got something started, i got some help from some of my classmates.
I really really need some major help. I am a complete beginner and not a computer guy so this class was always a challenge to me (for me tougher than Calc 3, haha)
so if anyone anyone at all can help me please please let me know so I can show you what i have so far. This is some really basic Java compared to what you guys do here. like first year high school java (so i was really hoping to see some light at the end of the tunnel by coming here).
Heres my Code so far:
import java.lang.Math;
import java.io.*;
import java.util.*;
public class DealOrNoDeal
{
Scanner in = new Scanner(System.in);
Scanner inFile;
private ArrayList <Double> money = new ArrayList <Double> (26);
private ArrayList <Double> moneyMix = new ArrayList <Double> (26);
private int myCase;
private double myCaseValue;
private int myRound = 1;
private int casesLeft = 6;
//stores money into cases randomly
public void setCases()
{
ArrayList <Double> temp = new ArrayList <Double> (money);
while (temp.size() != 0)
{
moneyMix.add(temp.remove((int)(Math.random()*temp.size())));
}
}
//gets money from file
public void getMoney()
{
try{
inFile = new Scanner(new File("dealmoney.txt"));
}catch(IOException i){
System.out.println("Error: "+ i.getMessage());
}
while (inFile.hasNext())
{
money.add(inFile.nextDouble());
}
/*for(int x=1; x<=26; x++)
System.out.print(money.get(x) + " ");*/
}
//asks user to pick case to keep
public void keepCase()
{
System.out.print("Keep case #: ");
myCase = in.nextInt();
myCaseValue = moneyMix.get(myCase - 1);
moneyMix.set(myCase-1,0.0);
}
//ask user case# choice
public void chooseCase()
{
System.out.println("Round " + myRound);
System.out.print(casesLeft + " cases left - ");
int chooseCase = in.nextInt();
moneyMix.set(chooseCase-1,0.0);
}
//displays cases
public void displayCases()
{
for(int x=1; x<=26; x++)
{
if(money.get(x-1) != 0)
System.out.print(x + " ");
else
System.out.print("X ");
}
System.out.println();
}
//displays money
public void displayMoney()
{
for(int x=1; x<=26; x++)
{
if(money.get(x-1) != 0)
System.out.print("$" + money.get(x-1) + " ");
else
System.out.print("X ");
}
System.out.println();
System.out.println();
}
//plays game
public void play()
{
getMoney();
setCases();
displayCases();
displayMoney();
keepCase();
chooseCase();
}
//runs program
public static void main(String[] args)
{
DealOrNoDeal game = new DealOrNoDeal();
game.play();
}
}
Please PM me or e-mail me at : viseshv@gmail.com
hope we can work together
But anyway,
I am taking Java in high school as my graduation requirement. And as our final project we are to make Deal or no Deal game on JCreator.
Now the most recent topic we covered was ArrayLists, we also covered topics like for/while loops, Exceptions and etc...
i have so far been able to print the money values and cases. So yea i got something started, i got some help from some of my classmates.
I really really need some major help. I am a complete beginner and not a computer guy so this class was always a challenge to me (for me tougher than Calc 3, haha)
so if anyone anyone at all can help me please please let me know so I can show you what i have so far. This is some really basic Java compared to what you guys do here. like first year high school java (so i was really hoping to see some light at the end of the tunnel by coming here).
Heres my Code so far:
import java.lang.Math;
import java.io.*;
import java.util.*;
public class DealOrNoDeal
{
Scanner in = new Scanner(System.in);
Scanner inFile;
private ArrayList <Double> money = new ArrayList <Double> (26);
private ArrayList <Double> moneyMix = new ArrayList <Double> (26);
private int myCase;
private double myCaseValue;
private int myRound = 1;
private int casesLeft = 6;
//stores money into cases randomly
public void setCases()
{
ArrayList <Double> temp = new ArrayList <Double> (money);
while (temp.size() != 0)
{
moneyMix.add(temp.remove((int)(Math.random()*temp.size())));
}
}
//gets money from file
public void getMoney()
{
try{
inFile = new Scanner(new File("dealmoney.txt"));
}catch(IOException i){
System.out.println("Error: "+ i.getMessage());
}
while (inFile.hasNext())
{
money.add(inFile.nextDouble());
}
/*for(int x=1; x<=26; x++)
System.out.print(money.get(x) + " ");*/
}
//asks user to pick case to keep
public void keepCase()
{
System.out.print("Keep case #: ");
myCase = in.nextInt();
myCaseValue = moneyMix.get(myCase - 1);
moneyMix.set(myCase-1,0.0);
}
//ask user case# choice
public void chooseCase()
{
System.out.println("Round " + myRound);
System.out.print(casesLeft + " cases left - ");
int chooseCase = in.nextInt();
moneyMix.set(chooseCase-1,0.0);
}
//displays cases
public void displayCases()
{
for(int x=1; x<=26; x++)
{
if(money.get(x-1) != 0)
System.out.print(x + " ");
else
System.out.print("X ");
}
System.out.println();
}
//displays money
public void displayMoney()
{
for(int x=1; x<=26; x++)
{
if(money.get(x-1) != 0)
System.out.print("$" + money.get(x-1) + " ");
else
System.out.print("X ");
}
System.out.println();
System.out.println();
}
//plays game
public void play()
{
getMoney();
setCases();
displayCases();
displayMoney();
keepCase();
chooseCase();
}
//runs program
public static void main(String[] args)
{
DealOrNoDeal game = new DealOrNoDeal();
game.play();
}
}
Please PM me or e-mail me at : viseshv@gmail.com
hope we can work together