Προς το περιεχόμενο

ΤάνιαΓ.

Members
  • ΜΗΝΥΜΑΤΑ FORUM

    12
  • ΜΕΛΟΣ

  • ΤΕΛ. ΕΠΙΣΚΕΨΗ

Σχετικά με ΤάνιαΓ.

  • Ημερομηνία γέννησης 09/03/1993

Πληροφορίες προφίλ

  • Φύλο
    Γυναίκα
  • Τοποθεσία
    Θεσσαλονίκη

ΤάνιαΓ.'s Achievements

Contributor

Contributor (7/15)

  • Πρώτο Μήνυμα
  • Collaborator
  • Εκκίνηση Συζήτησης
  • 1 Εβδομάδα Μετά
  • Ένα Μήνα Μετά

Πρόσφατες Διακρίσεις

0

Φήμη

  1. Καλησπέρα.. Χθες με βοηθήσατε να γράψω μία κλάση και με βοηθήστε πολύ μιας και είμαι αρχάρια.. Οπότε είπα να ρωτήσω ξανά..! Δεν ξέρω τι ακριβώς πρέπει να γράψω για να ελέγχετε η ορθότητα του κώδικά μου.. Βασικά δεν καταλαβαίνω καν τι είναι αυτά τα test.. Σαν ανεβάζω και τον κώδικα μου μήπως τον χρειάζεστε..! package com.example.crazysellout.UserSide; import java.io.BufferedReader; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; import java.util.Scanner; import android.R.string; import com.example.crazysellout.Offer; //Class that, reads the file of the data. public class OfferDataReader { List<string> lineArray; List<string> wordsArray; Offer ReadOffer(int indexLine){ string line = lineArray.get(indexLine); wordsInLine(line); Offer readedOffer = new Offer(); readedOffer.StoreName = wordsArray.get(0); readedOffer.ProductCategory = wordsArray.get(1); readedOffer.ProductName = wordsArray.get(2); readedOffer.ProductPrice = wordsArray.get(3); readedOffer.ProductDescription = wordsArray.get(4); return readedOffer; } //Diavazei kai apothikeyei se lista me Strings public void readDataFile(String path) throws IOException { ArrayList<String> lines = new ArrayList<String>(); Scanner s = new Scanner(new File(path)); //Diavazei grammi grammi kai tis apothikeyei while (s.hasNext()) { lines.add(s.next()); } s.close(); //Diatrexei ta strings kai gia kathe grammi kalei tin lineInWords for (String l : lines) { this.lineArray.add(l); } } //Xwrizei tis grammes se lekseis private void wordsInLine(string line) { String[] words = line.split(" "); for (String word : words) { this.wordsArray.add(word); } } }
  2. Σε ευχαριστώ που με βοήθησες..! Να'σαι καλά..!
  3. Το lineInWords που θα το γράψω και που θα το καλέσω..? Το fileOnTable μου λέει να το κάνω μέθοδο..!
  4. package com.example.crazysellout; public class Offer { //This is a struct of data that represents an offer. public String StoreName; public String ProductCategory; public String ProductName; public String ProductPrice; public String ProductDescription; } H Offer είναι αυτή.. Οι συναρτήσεις μου δεν καλούνται κάπου.. Αυτά που σας έγραψα πρέπει να τα κάνω εδώ.. Και το offers που επιστρέφεται το χρησιμοποιεί άλλη κλάση.. Πολύ χάλια τα έκανα ε..?!
  5. Είναι πολύ μεγάλο project για να το ανεβάσω όλο.. :/ Αν βοηθάει μπορώ να σου πω ότι το index Line δεν χρησιμοποιείται πουθενά και προφανώς έκανα λάθος.. Ότι δεν ξέρω καθόλου πως να δηλώσω τα attributes και να επιστρέψω το offers γι'αυτό και το λάθος με τον πίνακα και το super Που έχω βάλει είναι γιατί μου το έβγαζε σαν διόρθωση το eclipse.. Εγώ απλά προσπαθούσα να κάνω αυτό που έγραψα στο Post.. Αλλά μάλλον λανθασμένα..
  6. Ευχαριστώ που μου απάντησες..! Δεν βγάζει λάθος ο compliler απλά όταν παίρνει αυτά τα δεδομένα η κλάση που είναι να τα τυπώσει δεν εμφανίζει αποτελέσματα..! Απ'ότι κατάλαβα, γιατί είμαι νέα στην java μου λες ότι έχω αποθηκεύσει λάθος τις τιμές μου.. Πως να το κάνω για να αποθηκευτεί σωστά..?
  7. Έχω γράψει αυτήν την κλάση η οποία διαβάζει ένα text με προσφορές που σε κάθε του γραμμή έχει μία προσφορά η οποία περιλαμβάνει StoreName, ProductCategory, ProductName, ProductPrice, ProductDescription.. Μετά πρέπει να το χωρίζει σε λέξεις και να τις αποθηκεύει σε έναν πίνακα και τέλος μέσα στην ReadOffer να δίνει τιμές σε καθένα από τα παραπάνω και να τα αποθηκεύει στο αντικείμενο offers το οποίο και θα επιστρέφει.. Αλλά δεν μου τρέχει σωστά.. Μπορείτε να προτείνετε κάτι..? package com.example.crazysellout.UserSide; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import com.example.crazysellout.Offer; //Class that, reads the file of the data. public class OfferDataReader { String[] fileOnTable; Offer ReadOffer(int indexLine){ Offer offers = new Offer(); offers.StoreName = fileOnTable[0]; offers.ProductCategory = fileOnTable[2]; offers.ProductName = fileOnTable[3]; offers.ProductPrice = fileOnTable[4]; offers.ProductDescription = fileOnTable[5]; return offers; } //initialize txt reader with the input stream to set fileOnTable public OfferDataReader(InputStream iStream) throws IOException { super(); this.readDataFile(iStream); } //Method that reads the text file from resources and public void readDataFile(InputStream iStream) throws IOException { //String that gets each line of the text file in a while loop String stringContainer = null; String strW= null; //Variable in which the contex of the file will be stored StringBuffer strBuffer = new StringBuffer(); //Reads each line from the file. BufferedReader reader = new BufferedReader(new InputStreamReader(iStream)); while ((stringContainer = reader.readLine()) != null) { strBuffer.append(stringContainer + "\n"); } while ((strW = reader.readLine()) != null) { strBuffer.append(strW + " "); } } //Method that separates the string buffer to lines, and saves //on a table so that they can be identified as an account. public void textIndexOnTable(String indexOnString){ fileOnTable = indexOnString.split("\r\n|\r|\n"); } public void lineInWords(String indexOnString){ fileOnTable = indexOnString.split(" "); } }
  8. Καλημέρα παιδιά.. Προσπαθώ να γράψω μία κλάση ενός προγράμματος η οποία θέλω να διαβάζει ένα αρχείο txt γραμμή γραμμή και να επιστρέφει τα strings(λέξεις) της κάθε γραμμής σε μία λίστα.. Μπορεί να με βοηθήσει κάποιος..???
  • Δημιουργία νέου...