0

Recently I'm working on my project based on a program written by me in Pascal a year before. In this project I have to make it in to java and transform it to an app. I got stuck when I tried to declare variables. Here is my Pascal code:

const choiceno=15;
  maxword=1500;
  maxlen=20;

type stringtype = string[maxlen];
     wordtype = record
              words:stringtype;
              no:integer
            end;

var  diskfile,savetxt:text;
     style,aparno,eparno,wordno,wordpt,punno,choice,code,error:integer;
     strg:string[3];
     path:string;
     sensitive:boolean;
     wordct:array[1..maxword] of wordtype;
     letterno:array[97..122] of integer;
     capletno:array[65..90] of integer;

And I tried this in Java but it doesn't seem satisfying:

public final int ChoiceNo = 15;
public final int MaxWord = 1500;
public final int MaxLength = 20;
public String string ;
public int record;
public String Words;
public int No;
public String DiskFile;
public String Savetxt;
public int Style;
public int AparNo;
public int EparNo;
public int WordNo;
public int Wordpt;
public int PunNo;
public int Choice;
public int Code;
public int Error;
public String strg;
public String path;
public boolean Sensitive;
String[] WordCt = new String[MaxWord];
int[] LetterNo = new int[26];

The problem I faced is I don't have any ideas in declaring types in Java, can anyone provide me some help? Thanks a lot.

  • you can look at the data the variables hold and choose the type accordingly. – DevZer0 Jul 01 '13 at 07:09
  • I've edited and I put what I've done in Java, plz take a look – SalFire012 Jul 01 '13 at 07:18
  • define your custom type or structs in class,create a class in java and set your desire field for own type in it,then use it like new type anywhere on your app – Saeed-rz Jul 01 '13 at 07:20
  • Don't you think it would be convenient to first learn at least the basics of a language, before trying to make something in it? If you even have to ask about creating variables, how are you going to do the rest... – Stefan de Bruijn Jul 01 '13 at 07:29
  • Since I know the logic runs in the program so it isn't a problem for me to make changes in the program itself and the Pascal program itself is not very complicated at all. The only problem now is just thinking of how to declare types. – SalFire012 Jul 01 '13 at 07:33

0 Answers0