i'm so frustrated about my coding :( now i cant even get it right :(
assignment gonna due this coming week T^T
and i really need help
i hope you guys can really solve my problem for me T^T

so here is what i did so far ><

import java.util.ArrayList;
import java.util.Scanner;
import java.io.*;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.PrintWriter;
import java.io.IOException;



public class Auction
{

    private int displayPrice;
    private int increase;
    private int decrease;
    private ArrayList<String> profile; 
    private int BidPriceRangeNew;
    private int BidPriceRangeOld;
    
    
    public Auction()
    {
        profile = new ArrayList<String>();
    }
    
    public void propertyReadFromFile()
    {
        /**
         * Read datas from Property.txt
         */
        
    
        try
        {
         BufferedReader reader = new BufferedReader(new FileReader("property.txt"));
        String line = null;
            while ((line = reader.readLine()) != null)
            {
                int aInt = Integer.parseInt(line);
                System.out.println(line);
            }
        }catch(Exception e)
        {
            e.printStackTrace();
        }
        
    }
    
public void setDisplayPrice(int newDisplayPrice)
{
displayPrice = newDisplayPrice;
}

public int getDisplay()
{
return displayPrice;
}

public void increment(int increase)
{
increase++;
}

public void decrement(int decrease)
{
decrease--;
}

}

there would be a file that is called "property.txt" to read
and inside the .txt file it contains
1-100=1
101-200=2
201-300=3
301-400=4

how am i suppose to let my program know that my displayPrice is in that range so that the increment value is according to the range of value?

for example: if my displayPrice is 90 means after i read the file,
i have to know that my displayPrice will increase next to

read the lines as String objects
divide the String objects in parts and use if statements to check in which case you are.
just a basic question: how exactly do you think you can convert a String in which you have a - and a = character to an integer?

read the lines as String objects
divide the String objects in parts and use if statements to check in which case you are.
just a basic question: how exactly do you think you can convert a String in which you have a - and a = character to an integer?

ya.. thats what in my mind.. but i doesnt know how to code it ><

Well, as @stultuske said, read each line in your while loop. You'll need a variable, declared outside the loop, to hold the data you read. Probably a List of some type, though you could use an array []. When you read the line as a String object, you'll need to parse it into it's components. Use the split("=") method to get the values on either side of the "=". Then use split("-") to get the values on either side of the "-". Now you have the three bits of information, in String format, that you need to continue. You can use Integer.decode(...) to get the integer values of the Strings.

Hopefully, that should get you going.

Well, as @stultuske said, read each line in your while loop. You'll need a variable, declared outside the loop, to hold the data you read. Probably a List of some type, though you could use an array []. When you read the line as a String object, you'll need to parse it into it's components. Use the split("=") method to get the values on either side of the "=". Then use split("-") to get the values on either side of the "-". Now you have the three bits of information, in String format, that you need to continue. You can use Integer.decode(...) to get the integer values of the Strings.

Hopefully, that should get you going.

i get what you both means.. but the problem is i cant figure out the coding @@ :(

for the array thing.. you mean the following is it? i mean the

while ((line = reader.readLine()) != null)
            {
                int aInt = Integer.parseInt(line);
                System.out.println(line);
            }

change to

public void propertyReadFromFile()
    {
        /**
         * Read datas from Property.txt
         */
 
 
        try
        {
         BufferedReader reader = new BufferedReader(new FileReader("property.txt"));
        while (reader.ready())
                profileList.add(reader.readLine());
        }catch(Exception e)
        {
            e.printStackTrace();
        }
 
    }

int aInt = Integer.parseInt(line);

here you are trying to parse non-numerical info into an int. that is a compile time error waiting to kick you in the but. (figure of speech of yourse)
don't try to read this as an int or parse it into one.

you say you don't know how to read it into a String?
you already DO read it into a String, your String is: line.

now, separate the substrings and go from there.

why you all wont wana help me with the codes? :((
sigh
this is just my first time dealing with java things ><
im not experts okay :(

can someone please help me ?? ><

too late, far too late...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.