d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Need Assistance For My Java Assignment > Paying 1,000 Fg
Prev123
Add Reply New Topic New Poll
Member
Posts: 54,832
Joined: Jan 10 2009
Gold: 1,992.00
Oct 26 2015 12:16am
Code
import java.io.BufferedReader;
import java.io.InputStreamReader;

import javax.swing.JFrame;

public class flavor{

public static class Database{

final int IceCream = 16;
String[][] data = new String[IceCream][];

Database(String file) throws Exception
{
FileReader fr = new FileReader ("database.txt");
BufferedReader inFile = new BufferedReader(fr);
String_line = inFile.readLine();
String line;
StringTokenizer st = new StringTokenizer(line, ",");


int x = 0;
for(int i = 0; i < IceCream; i++){
for(int j=0; j<5; j++){
data[i][j] = st.nextToken();
}
line = inFile.readLine();
}
}
String[][] getData(){
return data;
}

class input {
String inStr() {
String str = new String();
BufferedReader br;

br = new BufferedReader(new InputStreamReader(System.in));

try{
str = br.readLine();
}
return str;
}
}

public static void main(String[] args){
createAndShowGUI();
}

public static void createAndShowGUI(){
//Create and show the GUI.
JFrame frame = new JFrame("Receipt");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(500,500);
frame.setLocation(200,200);
frame.setLayout(new GridLayout(2,1));

JTextArea textArea = new JTextArea(5, 20);
textArea.setEditable(false);
JScrollPane scrollPane = new JScrollPane(textArea);
frame.getContentPane().add(scrollPane);
JLabel label = new JLabel("");

textArea.setText("The Matrix should print here");

frame.pack();
frame.setVisible(true);

readAndDisplayMatrix(frame, textArea, label);
}

public static void main (string[] args){
//Variables
public static class Receipt {
private string code;
private string flavor;
private float price;
//Constructor
public produceItem(String c, String n, float p){
this.code=code;
this.flavor=flavor;
this.price=price;
}

public string getCode(){
return this.code;
}
public string getflavor(){
return this.flavor;
}
public string getPrice(){
return this.price;
}

public void setCode(string code){
this.code=code;
}

public void setflavor(string flavor){
this.flavor=flavor;
}

public void getPrice(float price){
this.price=price;
}

public string getCode(){
return code;
}

public string getflavor(){
return flavor;
}

public float getPrice(){
return price;
}
}
}
}


This is what I attempted so far. I pasted it into Eclipse and I am getting a bunch of syntax errors. What did I do wrong?
Member
Posts: 20,928
Joined: Mar 18 2009
Gold: 435,910.13
Oct 31 2015 08:04am
let me know if you need any help in the future, I need some fg :D

This post was edited by bakalolo on Oct 31 2015 08:05am
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Oct 31 2015 08:58am
Quote (Whalefood @ Oct 26 2015 02:16am)
Code
import java.io.BufferedReader;
import java.io.InputStreamReader;

import javax.swing.JFrame;

public class flavor{

public static class Database{

final int IceCream = 16;
String[][] data = new String[IceCream][];

Database(String file) throws Exception
{
FileReader fr = new FileReader ("database.txt");
BufferedReader inFile = new BufferedReader(fr);
String_line = inFile.readLine();
String line;
StringTokenizer st = new StringTokenizer(line, ",");


int x = 0;
for(int i = 0; i < IceCream; i++){
for(int j=0; j<5; j++){
data[i][j] = st.nextToken();
}
line = inFile.readLine();
}
}
String[][] getData(){
return data;
}

class input {
String inStr() {
String str = new String();
BufferedReader br;

br = new BufferedReader(new InputStreamReader(System.in));

try{
str = br.readLine();
}
return str;
}
}

public static void main(String[] args){
createAndShowGUI();
}

public static void createAndShowGUI(){
//Create and show the GUI.
JFrame frame = new JFrame("Receipt");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(500,500);
frame.setLocation(200,200);
frame.setLayout(new GridLayout(2,1));

JTextArea textArea = new JTextArea(5, 20);
textArea.setEditable(false);
JScrollPane scrollPane = new JScrollPane(textArea);
frame.getContentPane().add(scrollPane);
JLabel label = new JLabel("");

textArea.setText("The Matrix should print here");

frame.pack();
frame.setVisible(true);

readAndDisplayMatrix(frame, textArea, label);
}

public static void main (string[] args){
//Variables
public static class Receipt {
private string code;
private string flavor;
private float price;
//Constructor
public produceItem(String c, String n, float p){
this.code=code;
this.flavor=flavor;
this.price=price;
}

public string getCode(){
return this.code;
}
public string getflavor(){
return this.flavor;
}
public string getPrice(){
return this.price;
}

public void setCode(string code){
this.code=code;
}

public void setflavor(string flavor){
this.flavor=flavor;
}

public void getPrice(float price){
this.price=price;
}

public string getCode(){
return code;
}

public string getflavor(){
return flavor;
}

public float getPrice(){
return price;
}
}
}
}


This is what I attempted so far. I pasted it into Eclipse and I am getting a bunch of syntax errors. What did I do wrong?


why do you have so many classes in one file?
Go Back To Programming & Development Topic List
Prev123
Add Reply New Topic New Poll