Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

a)

Code Block
languagenone
function personProgram ()
    choice = -1;
    P = [];
    printHeader();
    while choice ~= 0
        printMenu();
        choice = input ('Velg et tall: ');
		clc
        if choice == 0
            continue;
        end
        P = process(P, choice);
    end
    printFooter();
end

...

Code Block
 function printFooter ()
    fprintf('Programmet avsluttes .\n');
end

e)

Code Block
languagenone
function P = processLoad ()
    fprintf ('Skal laste en fil \n');
end
 
function processStore(P)
    fprintf('Skal lagre en fil \n');
end
 
function processListPersons(P)
    fprintf('Skal skrive ut personene \n');
end
 
function P = processNewPerson(P)
    fprintf('Skal legge til en ny person \n');
end
 
function P = processChangePerson(P)
    fprintf('Skal endre en person \n');
end 

f)

Code Block
languagenone
 function P = process (P, choice )
    fprintf ('\n');
    switch choice
        case 1
            P = processLoad();
        case 2
            processStore(P);
        case 3
            processListPersons(P);
        case 4
            P = processNewPerson(P);
        case 5
            P = processChangePerson(P);
        otherwise
            fprintf ('%s\n', 'Ugyldig valg ');
    end
    fprintf ('\n');
end

...

Code Block
function processStore(P)
	filename = input ('Hvilken fil vil du lagre til ? ', 's');
	store(filename, P);
end

i)

Code Block
languagenone
function processListPersons(P)
	listPersons(P);
end % unødvendig, ja :)

j)

Code Block
function [newListOfPersons] = processNewPerson(listOfPersons)
    newData=batchRegisterPersons();
    newListOfPersons=[listOfPersons,newData];
end

...