Hello javaprogrammingforums,
I'm new here and new to the language.
I am trying to create a program as a side project to my studies but am having some difficulties.
I would like to create a simple record system that holds information like:
* Name
* Date of Birth
* Address
* etc
In this 'system' I would like a user be able to add new 'records' and edit or delete them once created.
I know some basics of the language and I've been playing with code for a few days now, i know WHAT i want to do and sort of the WAY in which it is done
but... i dont know HOW to go about writing it.
I currently have 2 .java files
here is the first:
class Student { private String name; private String DoB; private String term; private String home; private String course; private int fees; private String rela; private int marks; private String prog; public Student(String n, String d, String t, String h, String c, int f, String cr, int m, String p) { name = n; DoB = d; term = t; home = h; course = c; fees = f; rela = cr; marks = m; prog = p; } public String print() { return name + "\n" + DoB + "\n" + term + "\n" + home + "\n" + course + "\n" + fees + "\n" + rela + "\n" + marks + "\n" + prog; } public String toString() { return "These are the Current Stored Details:\n" + print(); } }
Which i think is still working fine, however my second file has become more tempermental during the week as i've been adding code, mainly because i am not certain on what i'm doing :/
.public class StudentTest { public static void main(String[] args) { String n; String d; String t; String h; String c; int f; String cr; int m; String p; Student[] kid; kid = new Student[1]; int i = 0; n = "Grant Searle"; d = "09/12/1991"; t = "Same as Home Address"; h = "5 James Road, Gosport, Hampshire, PO13 0TF"; c = "Computer Network Management & Design"; f = 3275; cr = "Mother"; m = 56; p = "Yes"; Student startingKid = new Student( n, d, t, h, c, f, cr, m, p ) ; kid[i] = startingKid; for (i = 0; i < kid.length; i++) System.out.println(kid[i]); do { KeyboardInput in = new KeyboardInput() ; System.out.println("What do you want to do?"); System.out.println("1) Add a Student Record"); System.out.println("2) Edit a Student Record"); System.out.println("3) Quit"); String answer = in.readString(); if(answer.equals("1") ){ System.out.println("Please Enter Student's Full Name:"); String inName = in.readString() ; System.out.println("Please Enter Student's Date of Birth:"); String inDate = in.readString() ; System.out.println("Please Enter Student's Term Address:"); String inTerm = in.readString() ; System.out.println("Please Enter Student's Home Address:"); String inHome = in.readString() ; System.out.println("Please Enter Student's Course Name:"); String inCourse = in.readString() ; System.out.println("Please Enter Student's Course Fees, £:"); double inFees = in.readDouble() ; System.out.println("Please Enter Student's Closest Relative:"); String inRela = in.readString() ; System.out.println("Please Enter Student's Marks:"); int inMarks = in.readInteger() ; System.out.println("Please Enter Student's Progression: (yes/no)"); String inProg = in.readString() ; } else if(answer.equals("2") ) { System.out.println("What is the Student's ID?"); //here i'd like some kind of index system so the user can type student 1 and that would edit array [0] by overwriting the 'stored' information // int studentNumber = Integer.parseInt(in.readString()); // for(int y=0; y < newEntry; y++) // { // if(studentNum[y] == studentNumber) //found the student //do the adding of new details, submit and overwrite //} } } while(!answer.equals("3")); // later add a delete option, ie. move current array into temp smaller array to shift elements instead of making null } }
In this second file, i have 1 person stored to begin with so the user can edit or delete right from the start.
However i am having trouble with the rest, i know there is a lot to be added and changed as
I've made mistakes and my syntax is probably horrid but if anyone could help me out i'd really appreciate it.
Thank you


LinkBack URL
About LinkBacks
Reply With Quote
